fn calc(val: usize) -> usize { let cnt = (val as f64).sqrt().floor() as usize; let cnt = cnt + (val as f64 / 2.).sqrt().floor() as usize; cnt } fn solve() -> usize { let mut lr = String::new(); std::io::stdin().read_line(&mut lr).ok(); let lr: Vec = lr.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let l = lr[0]; let r = lr[1]; (calc(r) - calc(l-1)) % 2 } fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let mut result = Vec::with_capacity(t); for _ in 0..t { result.push(solve()); } for &v in result.iter() { println!("{}", v); } /* for i in 1..=100 { let mut factorsum = 0usize; for j in 1..=i { if i % j == 0 { factorsum += j; } } println!("{} {}", i, factorsum % 2); } */ }