for _ in range(int(input())): def bd(n,cul,ud): def j(x,y,ud): if ud == ">=": if x >= y:return True else:return False else: if x <= y: return True else:return False l = 0 r = 316227710 while r-l > 1: mid = (r+l) //2 if j(cul(mid),n,ud): if ud == ">=":r = mid else:l = mid else: if ud == ">=":l = mid else:r = mid if ud == ">=":return r else:return l ans = 0 l,r = map(int,input().split()) ans += bd(r,lambda x:x**2,"<=") - bd(l,lambda x:x**2,">=") + 1 ans += bd(r,lambda x:2*x**2,"<=") - bd(l,lambda x:2*x**2,">=") + 1 if ans & 1: print(1) else: print(0)