题目
线性基是学线性代数上出现的概念,没想到那么有用。把一个集合弄成一个极大线性无关子集,就能把他所能表示的数都能存起来。求第k小我也不会证。。就当先存个板子吧

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (int i = (n); i < (m); i++)
#define _rep(n,m,i) for (int i = (n); i <= (m); i++)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
struct Liner_Basis{
  LL d[63], f[63], tot;
  bool flag;
  Liner_Basis() {memset(d, 0, sizeof(d)), memset(f, 0, sizeof(f));tot = 0;flag = false; }
  void insert(LL x) {
    for(int i = 62; i >= 0; i--) {
      if((x >> i )& 1) {
        if(!d[i]) {
          d[i] = x;
          return ;
        }
        x ^= d[i];
      }
    }
    flag = true;
  }
  void rebuild() {
    for(int i = 62; i >= 0; i--) {
      for(int j = i-1; j >= 0; j--) {
        if(d[i] >> j & 1) d[i] ^= d[j];
      }
    }
    for(int i = 0; i <= 62; i++) if(d[i]) f[tot++] = d[i];
    return ;
  }
  LL k_th(LL k) {
    if(flag) k--;
    if(k == 0) return 0;
    LL num = 0;
    if(k >= (1ll << tot)) return -1;
    for(int i = 62; i >= 0; i--) {
      if(k >> i & 1) num ^= f[i];
    }
    return num;
  }
};
int main() {
  fio
  int t;
  cin >> t;
  for(int ci = 1; ci <= t; ci++) {
    int n;LL x;Liner_Basis LB;
    cin >> n;
    while(n--) {
      cin >> x;
      LB.insert(x);
    }
    LB.rebuild();
    cin >> n;
    cout << "Case #" << ci << ":\n";
    while(n--) {
      cin >> x;
      cout << LB.k_th(x) << endl;
    }
  }
}