#K44162. Longest City Name

    ID: 27471 Type: Default 1000ms 256MiB

Longest City Name

Longest City Name

You are given (T) test cases. For each test case, you are given an integer (N), representing the number of cities, followed by (N) city names (each name may include spaces). Your task is to determine the city with the longest name for each test case. In the event of a tie (i.e. two or more cities having the same maximum length), output the city that appears first in the input order.

The logic behind the solution can be summarized by the condition: if ( |city| > |longest| ) then update (longest).

inputFormat

The input is read from standard input (stdin) and is structured as follows:

(T) — the number of test cases. For each test case:
(N) — the number of cities.
Then (N) lines follow, each containing a city name. City names may contain spaces.

outputFormat

For each test case, print the city with the longest name on a new line. The output should be written to standard output (stdout).## sample

2
3
Paris
London
Tokyo
4
Rome
Amsterdam
Berlin
Madrid
London

Amsterdam

</p>