#include using namespace std; #define REP(i, n) for(int i=0;i<(n);++i) #define int long long const long long MOD = 1e9+7; typedef vector INTV; using BitMatrix = vector; BitMatrix merge(BitMatrix a, BitMatrix b){ BitMatrix c(a.size() + b.size()); REP(i, a.size()) c[i] = a[i]; REP(i, b.size()) c[a.size()+i] = b[i]; int rank = 0; for(int col = 31; col >= 0; col--){ int pivot = -1; for(int row = rank; row < c.size(); row++){ if((c[row] >> col) & 1){ pivot = row; break; } } if(pivot == -1) continue; swap(c[pivot], c[rank]); REP(row, c.size()){ if(row != rank and ((c[row] >> col) & 1)) c[row] ^= c[rank]; } rank++; } BitMatrix res(rank); REP(i, rank) res[i] = c[i]; return res; } int siz; vector> table; vector logtable; void SparseTable_init(vector vec){ siz = vec.size(); logtable.resize(siz+1, 0); for(int i = 2; i <= siz; i++){ logtable[i] = logtable[i >> 1] + 1; } table.resize(siz, vector(14)); REP(i, siz){ table[i][0] = vec[i]; } } void build(void){ for(int k = 1; (1<> N >> Q; vector vec(N, BitMatrix(1)); REP(i, N) { int a; cin >> a; vec[i][0] = a; } SparseTable_init(vec); vector().swap(vec); build(); int M; REP(_, Q){ cin >> M; INTV B(M+2); B[0] = 0; B[M+1] = N; int pw = N; REP(i, M){ cin >> B[i+1]; } REP(i, M+1){ pw -= query(B[i], B[i+1]).size(); } cout << powmod(2ll, pw, MOD) << endl; } }