Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Which One Is Larger?

By S_Rifat · Limits 1s, 512 MB

You will be given two integers l and r where l ≤ r. There are three functions named F0, F1 and F2.
These functions are described as below:

FUNCTION F0 (ARGUMENT a, ARGUMENT b)
  RETURN a × b
END F0
FUNCTION F1 (ARGUMENT  l, ARGUMENT r) 
  IF l == r
    RETURN r
  END IF
  a ← l
  b ← F1 (l + 1, r)
  c ← F0 (a, b)
  RETURN c
END F1
FUNCTION F2 (ARGUMENT l, ARGUMENT r)
  x ← r - l + 1
  z ← l
  y ← x - 1
  m ← 2 × z
  RETURN (x × (m + y)) / 2
END F2

Let, A = F2(l, r) and B = F1(l, r). Can you determine which one is larger between A and B?

Input

First line of input consists of a single integer T (1 ≤ T ≤ 100000) that denotes the number of test cases. Next T lines are followed by two integers l and r.

10100lr10100-10^{100} ≤ l ≤ r ≤ 10^{100}

Output

If A is larger than B, print “0”. If B is larger than A, print “1”. When it is not possible to determine which one is larger, print “-1”.

Sample

InputOutput
1
1 10

1

    Discussion

    Statistics


    39% Solution Ratio

    fsshakkhorEarliest, 6M ago

    Deshi_TouristFastest, 0.0s

    dUfReSnELightest, 262 kB

    NirjhorShortest, 415B

    Submit

    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.