#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
const int MAXN = 1e5 + 13;
const int MAXL = 21;
const int INF = 1e9 + 7;
int N, Q;
int arr[MAXN];
vector<pair<int, int> > query[MAXN];
int ans[MAXN];
int basis[MAXL];
int pw2[MAXN];
int B = 0;
int32_t main() {
  cout << fixed << setprecision(12);
  cerr << fixed << setprecision(4);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  for (auto i = (0); i < (N); i++) {
    cin >> arr[i];
  }
  pw2[0] = 1;
  for (auto i = (0); i < (N); i++) {
    pw2[i + 1] = pw2[i] + pw2[i];
    if (pw2[i + 1] >= INF) pw2[i + 1] -= INF;
  }
  for (auto i = (0); i < (Q); i++) {
    int l, x;
    cin >> l >> x;
    l--;
    query[l].push_back({x, i});
  }
  for (auto i = (0); i < (N); i++) {
    int x = arr[i];
    for (auto j = (MAXL)-1; j >= (0); j--) {
      if (basis[j] == 0) continue;
      ckmin(x, basis[j] ^ x);
    }
    if (x != 0) {
      B++;
      for (auto j = (MAXL)-1; j >= (0); j--) {
        if (basis[j] != 0) {
          ckmin(basis[j], basis[j] ^ x);
        } else if (x & (1 << j)) {
          basis[j] = x;
          break;
        }
      }
    }
    for (pair<int, int> q : query[i]) {
      for (auto j = (MAXL)-1; j >= (0); j--) {
        if (basis[j] == 0) continue;
        ckmin(q.first, q.first ^ basis[j]);
      }
      if (q.first != 0) {
        ans[q.second] = 0;
      } else {
        ans[q.second] = pw2[i + 1 - B];
      }
    }
  }
  for (auto i = (0); i < (MAXL); i++) {
    if (basis[i] == 0) continue;
    for (auto j = (i + 1); j < (MAXL); j++) {
      if (basis[j] == 0) continue;
      assert((basis[j] ^ basis[i]) >= basis[j]);
    }
  }
  for (auto i = (0); i < (Q); i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
