#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
template <class T>
T read(T &x) {
  char c;
  int flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag *= -1;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= flag;
  return x;
}
long long n, q;
struct linear_basis {
  long long b[22];
  void add(long long x) {
    for (long long i = 20; i >= 0; --i)
      if (x & (1LL << i)) {
        if (!b[i]) {
          b[i] = x;
          break;
        } else
          x ^= b[i];
      }
  }
  bool express(long long x) {
    for (long long i = 20; i >= 0; --i)
      if (x & (1LL << i)) x ^= b[i];
    return x == 0;
  }
  long long size() {
    long long ret = 0;
    for (long long i = 0; i <= 20; ++i)
      if (b[i]) ret++;
    return ret;
  }
} p[100005];
long long pw(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  memset(p[0].b, 0, sizeof p[0].b);
  ;
  for (long long i = 1; i <= n; ++i) {
    p[i] = p[i - 1];
    long long x;
    cin >> x;
    p[i].add(x);
  }
  for (long long i = 1; i <= q; ++i) {
    long long l, x;
    cin >> l >> x;
    if (p[l].express(x))
      cout << pw(2, l - p[l].size()) << "\n";
    else
      cout << "0\n";
  }
}
