use proconio::input; fn main() { input! { t:usize, } for _ in 0..t { input! { l:usize, r:usize, } let ans = (2 + f(r) % 2 - f(l - 1) % 2) % 2; println!("{}", ans); } } const NG: usize = 100000000; fn f(m: usize) -> usize { let is_ok0 = |x| x * x <= m; let is_ok1 = |x| x * x * 2 <= m; (nibutan(0, NG, is_ok0) % 2 + nibutan(0, NG, is_ok1) % 2) % 2 } fn nibutan(mut ok: usize, mut ng: usize, is_ok: F) -> usize where F: Fn(usize) -> bool, { while ng - ok > 1 { let mid = (ok + ng) / 2; if is_ok(mid) { ok = mid; } else { ng = mid; } } ok }