import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int T;
        T=cin.nextInt();
        BigInteger a,b;
        for(int cas=1;cas<=T;cas++){
            a=cin.nextBigInteger(2);
            b=cin.nextBigInteger(2);
            a=a.gcd(b);
            System.out.println("Case #"+cas+": "+a.toString(2));
        }
    }
}