using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; //using static CompLib.CompLib; //using DataStructure; namespace atcoder { class Program { const int intMax = 1000000000; const long longMax = 2000000000000000000; static void Main(string[] args) { int T = int.Parse(Console.ReadLine()); while (T-- > 0) { var LR = Console.ReadLine().Split().Select(long.Parse).ToArray(); Console.WriteLine(solve(LR[0], LR[1])); } long solve(long l, long r) { long check(long x) { if (x == 0) return 0; long ok = 0; long ng = 1000000001; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (mid * mid <= x) ok = mid; else ng = mid; } long ret = ok; ok = 0; ng = 1000000001; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (2 * mid * mid <= x) ok = mid; else ng = mid; } ret += ok; return ret; } long ret = check(r) - check(l - 1); return ret % 2; } } } }