#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 10;
const int mod = 1e9 + 7;
vector<int> dic;
vector<pair<int, int> > query[MAX_N];
int a[MAX_N], ans_q[MAX_N];
bool in_dic[(1 << 20) + 10];
int main() {
  int n, q, l, x;
  scanf("%d%d", &n, &q);
  dic.reserve((1 << 20) + 5);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &l, &x);
    query[l].push_back(pair<int, int>(x, i));
  }
  in_dic[0] = true;
  dic.push_back(0);
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    if (in_dic[a[i]])
      ans = ans * 2 % mod;
    else {
      int cur_size = (int)dic.size();
      for (int j = 0; j < cur_size; j++) {
        dic.push_back(dic[j] ^ a[i]);
        in_dic[dic[j] ^ a[i]] = true;
      }
    }
    for (pair<int, int>& p : query[i]) ans_q[p.second] = ans * in_dic[p.first];
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans_q[i]);
  return 0;
}
