Limits 1s, 512 MB

“Stop War, Save Life” – A life-changing motto proposed by Peace Want Society (PWS).

To establish this motto the CEO of PWS Mr. Savior has to face several challenges. Being busy to get out from a weird map the evil guys set up another challenge. This time they want to let Mr. Savior eat. The evil guys make a rectangular dark forest cake. A honey drop has been placed on top of the cake. The evil guys connect all four corners by margarine stick with that honey drop. Let’s have a look at the picture below –

Here ABCDABCD is the cake. The honey drop is placed on the point OO. Here OA=KOA = K, OB=LOB = L, OC=MOC = M, OD=NOD = N. The evil guys somehow managed to calculate the size of any three margarine stick. Mr. Savior has to figure out the size of the left margarine stick. Mr. Savior will encounter queries of 4 different types.

  • For the query of Type – 1, Mr. Savior will be given the value of LL, MM, NN. He has to find the value of KK.

  • For the query of Type – 2, Mr. Savior will be given the value of KK, MM, NN. He has to find the value of LL.

  • For the query of Type – 3, Mr. Savior will be given the value of KK, LL, NN. He has to find the value of MM.

  • For the query of Type – 4, Mr. Savior will be given the value of KK, LL, MM. He has to find the value of NN.

Input

Input starts with an integer TT (1T1051 ≤ T ≤ 10^5) which denotes the number of test cases. Each of the next TT lines contains four integers. The first integer QQ (1Q41 ≤ Q ≤ 4) denotes the query type. The second, third and fourth integer will be the values of either LL, MM, NN or KK, MM, NN or KK, LL, NN or KK, LL, MM (1K,L,M,N1091 ≤ K, L, M, N ≤ 10^9) based on the query type as described above.

Input will be given as such the answer will always be valid.

Output

For each test case, you need to print the size of the margarine stick that is not given in the input in the following format. Errors will be ignored after 4 decimal points.

Sample

InputOutput
2
4 4 6 5
3 4 6 5
2.2361
6.7082

Submit

Login to submit.

Statistics

83% Solution Ratio
IOI_StfuFfsEarliest, Mar '18
Kuddus.6068Fastest, 0.1s
minhazmirazLightest, 1.6 MB
CoderFolderShortest, 458B
Toph uses cookies. By continuing you agree to our Cookie Policy.