import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static int merge(Map<Long, Integer> map) {
        for (Map.Entry<Long, Integer> i : map.entrySet()) {
            for (Map.Entry<Long, Integer> j : map.entrySet()) {
                if (!i.getKey().equals(j.getKey()) && (i.getKey() & j.getKey()) >= 1) {
                    int tmp = i.getValue() + j.getValue();
                    long tmpV = i.getKey() | j.getKey();
                    map.remove(i.getKey());
                    map.remove(j.getKey());
                    map.merge(tmpV, tmp, Integer::sum);
                    return 1;
                }
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            int n = in.nextInt();
            //map的key是这个网络的状态,value是网络成员数;(一个数 & key) >= 1则加到该网络
            Map<Long, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                long x = in.nextLong(), flag = 0;
                for (Map.Entry<Long, Integer> en : map.entrySet()) {
                    if ((en.getKey() & x) >= 1) {
                        //x加入某个网络
                        Integer value = en.getValue();
                        map.remove(en.getKey());
                        map.merge(en.getKey() | x, value + 1, Integer::sum);
                        flag = 1;
                        break;
                    }
                }
                //如果x没有加到其它网络,则自己创建一个
                if (flag == 0) map.merge(x,1, Integer::sum);
            }
            //循环合并网络,网路是按位压缩枚举的,所以数量不会超过20个
            while (merge(map) == 1) ;
            int ans = 0;
            for (Integer j : map.values()) ans = Math.max(ans, j);
            System.out.println(ans);
        }
        in.close();
    }
}