#K68312. Longest Word Finder

    ID: 32837 Type: Default 1000ms 256MiB

Longest Word Finder

Longest Word Finder

You are given several sentences. For each sentence, your task is to determine the longest word contained in it. In case there are multiple words with the maximum length, return the first one encountered.

The input begins with an integer \(T\) indicating the number of sentences. Each of the next \(T\) lines contains a single sentence. For each sentence, print the longest word on a new line.

Note: If there are several words of the same maximum length, output the first one that appears in the sentence.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
sentence 1
sentence 2
... 
sentence T

Here, \(T\) is an integer representing the number of test cases, and each subsequent line is a sentence composed of words separated by spaces.

outputFormat

For each test case, print the longest word found in the corresponding sentence to standard output (stdout), each on a separate line. In case of a tie in length, print the word that appears first.

## sample
3
explode the possibilities
coding is great fun
write efficiently
possibilities

coding efficiently

</p>