import sys input = sys.stdin.readline T=int(input()) for t in range(T): L,R=map(int,input().split()) print(0 if L%2==0 and R%2==1 else 1)