#Lutece0540. SaSet
SaSet
Migrated from Lutece 540 SaSet
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Saya defines a set consists of square numbers( or ) called Saya Set(SaSet
for short). The addition on this set is defined by Saya:
$a+1(a\in SaSet)=min(\left \{x\mid x>a,x\in SaSet\right \})$
( here is a function which returns the minimum element in the given set . For example, .)
Examples:
, ,
$a-1(a\in SaSet)=max(\left \{x\mid x<a, x\in SaSet\right \})$
( here is a function which returns the maximum element in the given set .)
Example:
, ,
Example:
Input
There is only one integer () in the first line, which denotes the number of test cases.
Then T lines follows, each line will consists of two integers and (,). You are asked to calculate the answer of .
Output
For each case, output an integer, which denotes the result of according to the definitions above.
Samples
2
0 0
4 4
0
16
Resources
Saya Mathematics@蒲公英的黄昏