use std::io::Write; fn main () { let stdout = std::io::stdout(); let mut writer = std::io::BufWriter::new(stdout.lock()); let s: usize = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().parse().unwrap() }; for _ in 0..s { let (x, y): (i64, i64) = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) }; let p = x + y; let q = (x - y).abs(); let mut ans = 0; let mut i = 1; while i * i <= q { if q % i > 0 { i += 1; continue; } let j = q / i; if p % (i + 2) == 0 { let u = p / (i + 2); let v = j; if u > v && (u + v) % 2 == 0 { ans += 1; } } if i != j && p % (j + 2) == 0 { let u = p / (j + 2); let v = i; if u > v && (u + v) % 2 == 0 { ans += 1; } } i += 1; } writeln!(writer, "{}", ans).unwrap(); } }