#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q, m = 32000000; cin >> Q; vector sq(m + 1), sq2(m + 1); for(ll i = 1; i <= m; i++){ sq[i] = i * i; sq2[i] = sq[i] << 1; } while(Q--){ ll L, R; cin >> L >> R; bool ans = upper_bound(sq.begin(), sq.end(), R) - lower_bound(sq.begin(), sq.end(), L) & 1; ans ^= upper_bound(sq2.begin(), sq2.end(), R) - lower_bound(sq2.begin(), sq2.end(), L) & 1; cout << ans << '\n'; } }