import java.util.Scanner;

/**
 * @author supermejane
 * @date 2025/10/12
 * @description
 */
public class Main {
	//我只按题目推导到i = x ^ y ^ j, i + 1 = x ^ y ^ (j + 1), ......当然x ^ y是已经知道的常数
  	//对于x ^ y末尾的....0111000为例子, 对于i(inde且从1开始)从1000 ~ 1111/11000 ~ 11111/111000 ~ 111111都是可以取到最多的相同子串,当然题目例子三是综合考虑了两个串,希望尽量取少数组展现取得i = 12, j = 16
  	//至于为什么这样可以取到最长相同字串,我也不知道证明。
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        while (n-- > 0) {
            int k = in.nextInt() ^ in.nextInt();
            int cnt = 0;
            while ((k & 1) == 0) {
                cnt++;
                k >>= 1;
            }
            System.out.println(1 << cnt);
        }
    }
}