use std::io::{self, Read};
fn cmmdc(mut a: u64, mut b: u64) -> u64 {
while b != 0 {
let r = a % b;
a = b;
b = r;
}
a
}
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let mut iter = input.split_whitespace();
let t: usize = iter.next().unwrap().parse().unwrap();
let mut output = String::new();
for _ in 0..t {
let a: u64 = iter.next().unwrap().parse().unwrap();
let b: u64 = iter.next().unwrap().parse().unwrap();
output.push_str(&format!("{}\n", cmmdc(a, b)));
}
print!("{}", output);
}