Third Largest Number

Interview

Time limit1sMemory limit32 MB

Summary
For each test case of 10 positive integers, output the third largest distinct-position value in the array.
Level

Easy2 of 10

Topics
Sorting, Array
Solved
No attempts yet

Problem

Given an array A, write a program that prints the third largest value in the array.

The size of A is always 10, and every element is a positive integer. The requested rank is always 3.

Input

The first line contains the number of test cases T (1 ≤ T ≤ 1,000). Each test case is given on one line and contains 10 elements of array A separated by spaces. Each element is a positive integer from 1 to 1,000 inclusive.

Output

For each test case, print the third largest value in array A on its own line.

Examples1

  1. Example 1

    Input
    4
    1 2 3 4 5 6 7 8 9 1000
    338 304 619 95 343 496 489 116 98 127
    931 240 986 894 826 640 965 833 136 138
    940 955 364 188 133 254 501 122 768 408
    
    Expected output
    8
    489
    931
    768