/* -*- coding: utf-8 -*- * * 1895.cc: No.1895 Mod 2 - yukicoder */ #include #include #include using namespace std; /* constant */ /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ inline int sigmaf(ll n) { return (int)sqrt(n + 0.5) + (int)sqrt(n / 2 + 0.5); } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { ll l, r; scanf("%lld%lld", &l, &r); int x = sigmaf(r) - sigmaf(l - 1); printf("%d\n", x & 1); } return 0; }