#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int ddx[] = {-1, -2, 1, -2, 2, -1, 2, 1}, ddy[] = {-2, -1, -2, 1, -1, 2, 1, 2};
int a[200001], ans[200000];
vector<pair<int, int> > v[200001];
bool chk[1 << 20];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) scanf("%d", a + i);
  for (int(i) = (0); (i) <= (q - 1); (i) += (1)) {
    int l, x;
    scanf("%d%d", &l, &x);
    v[l - 1].push_back(make_pair(x, i));
  }
  int res = 1;
  vector<int> vv = {0};
  chk[0] = 1;
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {
    if (chk[a[i]])
      res = (res * 2) % MOD;
    else {
      int t = vv.size();
      for (int(k) = (0); (k) <= (t - 1); (k) += (1)) {
        vv.push_back(vv[k] ^ a[i]);
        chk[vv[k] ^ a[i]] = 1;
      }
    }
    for (pair<int, int> P : v[i]) {
      if (chk[P.first]) ans[P.second] = res;
    }
  }
  for (int(i) = (0); (i) <= (q - 1); (i) += (1)) printf("%d\n", ans[i]);
}
