#K60797. Sentence Modifier Commands
Sentence Modifier Commands
Sentence Modifier Commands
You are given a sentence and a list of commands. Each command instructs you to modify the sentence in a particular way. The commands are applied sequentially. There are three types of commands:
- Upper n: Convert the first n words of the sentence to uppercase.
- Lower n: Convert the last n words of the sentence to lowercase.
- Reverse n: Reverse the order of the first n words.
If there are fewer than n words in the sentence for a given command, apply the command to all available words. If no commands are provided, output the sentence unchanged.
Note: All modifications are applied in the order in which the commands are given.
inputFormat
The input is read from standard input (stdin) and has the following format:
<sentence> <number_of_commands> <command1> <command2> ... <commandN>
Here, the first line is the sentence (words separated by spaces), the second line is an integer specifying the number of commands, followed by that many lines each containing a command.
outputFormat
Output the modified sentence using standard output (stdout) after all commands have been applied.
## samplehello world here I am
1
Upper 3
HELLO WORLD HERE I am