"NEW FUN" (LATVIA)

Programmers often are asked to rewrite old program and the new program version must keep its functionality. It is nice, if such program is well documented and source code is available. But not always life is so lucky.
You must rewrite earlier written function FUN about which is known the following:
1) FUN's arguments are 4 positive integers a1,a2,a3 and a4,
2) FUN's value is one of its arguments values,
3) FUN performs one function of the following kind:

IF ai op aj THEN FUN:=ak ELSE FUN:=am ;

where possible op values are< , £ , > , ³ , = , ¹, and 1 £i,j,k,m£4.

If i=1, j=2, k=4, m=1, and op is '¹', then we get function

IF a1¹a2 THEN FUN:=a4 ELSE FUN:=a1;()

and we will obtain, for example,FUN(2,1,1,3) = 3, FUN(4,4,2,3) = 4.

It is known, that in practice the existing version is too slow and works properly only if its argument values doesn't exceed 5. You are asked to write a new function version which has to work properly for all positive integer values which do not exceed 32767.

Old FUN version is written so, that this, exactly which function is performed depends on data file in the current catalog FUN.DAT - so it will not be enough if you write a version which performs the same function as old FUN for one fixed FUN.DAT. New version must work properly for any provided FUN.DAT .

Your program will always work in the same environment as old FUN, so you may include in your program old FUN calls (of course, keeping in mind restrictions for argument values). You can asume that in the current catalog always will be valid file FUN.DAT and your new program never will be used without it.

You must write program which performs the same function as old FUN (for any provided FUN.DAT) and for argument values given in input file calculates function values and output them to output file.

The execution time of a call to the old FUN depends neither on the argument values nor on the file FUN.DAT.

Input data

In the first line of text file NEWFUN.IN number of argument sets N (1£N£1000) is given. In the each of the following N lines one argument set (four positive integer values separated by single space characters) is given. All argument values are less or equal to 32767.

Output data

Text file NEWFUN.OUT must contain exactly N rows. In the i-th file row one positive integer - "new FUN" value for i-th argument set must be written.

Technical information for Pascal users

On the diskette in the subdirectory /FUN_PAS the following files are given:

Technical information for C/C++ users

On the diskette in the subdirectory /FUN_C the following files are given:

For proper funit.obj using, you must: Example Input data (File NEWFUN.IN)             Output data(File NEWFUN.OUT)
5                       3
2 1 1 3                 4
4 4 2 3                 32766
32767 1 1 32766         6
6 6 6 6                 10
7 8 9 10  
Remark: In the given example the last three sets will not be processed properly by old FUN version.

TEST CASES

NEXT TASK