#C6137. Longest Word Finder

    ID: 49864 Type: Default 1000ms 256MiB

Longest Word Finder

Longest Word Finder

You are given a sentence and your task is to find the longest word in that sentence. If there are several words with the maximum length, output the first one that appears.

In this problem, the input starts with an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a sentence. For each sentence, you are to output the longest word on a new line.

Note: A word is defined as a maximal substring consisting of non-space characters. Use the standard whitespace as the word delimiter.

inputFormat

The first line contains an integer \(T\) denoting the number of test cases. Each of the next \(T\) lines contains a sentence.

Example:

5
 the quick brown fox
 jumps over the lazy dog
 a quick movement of the enemy
 hello world
 longer longest long

outputFormat

For each test case, output a single line containing the longest word in the corresponding sentence. If there are multiple words with the same length, output the first one encountered.

Example Output:

quick
jumps
movement
hello
longest
## sample
1
the quick brown fox
quick

</p>