import java.util.*; public class LANQIAO1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int x ,y; for (int i = 0; i < t; i++) { x = sc.nextInt(); y = sc.nextInt(); System.out.println(f(x , y)); } } private static int f(int x, int y) { if(y == 0) return x; else return f(y, x % y); } }