#include using namespace std; using ll = long long; using P = pair; #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a1){ ll md = (ng+ok)/2; if(md*md<=x) ok = md; else ng = md; } return ok; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t; cin >> t; rep(houren,t){ ll l,r; cin >> l >> r; l--; cout << (cal(r)+cal(r/2)-cal(l)-cal(l/2))%2 << '\n'; } return 0; }