#K40147. Taco Title Formatter

    ID: 26578 Type: Default 1000ms 256MiB

Taco Title Formatter

Taco Title Formatter

Given a list of book titles, you are required to format each title according to specific capitalization rules. For each title (a sequence of words), small words (i.e., (\text{and, the, in, of, on, at, by, with, a, an, but, for, nor, or, so, yet})) should be output in lowercase unless they are the first or the last word of the title. All other words must have their first letter in uppercase and the rest in lowercase.

inputFormat

The first line contains an integer (T) denoting the number of book titles. Each of the next (T) lines contains a single book title.

outputFormat

Output (T) lines where each line contains the formatted book title according to the rules described.## sample

1\nthe great gatsby\n
The Great Gatsby\n