OPBIT - Operation Bits

Operation bits - A new operation conducted by the secret team currently working on a project on security enhancement. Mr.Abay, the team head, has found a new pattern on the perfect squares. This can be used as a outer cover for his project as its securing power is low. So he assign you this problem to find the key based on the given conditions:

"An two adjacent perfect squares have their absolute difference as an odd number except when a and b are equal. Your task is to find the key which is defined as: 

key(a, b) where a and b are perfect squares is ( ( AND( absolute difference between every adjacent perfect squares in [a, b]) ) AND ( XOR( absolute difference between every adjacent perfect squares in [a, b]) ) )"

Find the key for the given inputs :)

Input

The input begins with a number T (1<=T<=1000) where T is the number of testcases.

T lines follow

Each line has two numbers a and b (0 < a <= b <= 10^6)

It is assured that a and b are perfect squares.

Output

For each test case print the corresponding key.

Example

Input:
2
1 4
25 49

Output:
3
0

for test case 1 we have key=(3)&(3)=3


Added by:Benkindersophobia
Date:2013-11-30
Time limit:0.100s
Source limit:40000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:My Own

hide comments
2014-01-22 19:49:17 treasurer
if a==b then??
2014-01-22 14:59:50 Aravindan Chandrasekaran
AC in 1st go !
2014-01-06 12:23:00 Martijn Muijsers
Fifth half century! Good problem :D
2014-01-02 08:37:21 Ashwini
ac in 1st attempt:)
2013-12-22 17:28:29 daft_wullie
Nice Problem, enjoyed solving it!
@Benkindersophobia: Is it possible to adjust the time limit for python 3?
2013-12-20 16:52:33 Kevin Sebastian
@author..what is the answer if a=b?
2013-12-14 08:16:03 Bhavik
one test case:
1
1 1000000
1
2013-12-13 19:31:08 ήάέέϻ Ÿ
can you please provide some more test cases. My solution fails for input case 3. :(
2013-12-12 19:42:55 Bhavik
easy but do carefully!!!
2013-12-04 11:00:04 [Lakshman]
@Benkindersophobia Can you please tell me where my solution fails, Or mt algorithm is wrong?
Got it.

EDIT: AC.

Last edit: 2013-12-04 12:04:00
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.