#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 100005;
int ans[N], basis[30], pw[N], a[N];
vector<pair<int, int>> query[N];
int cnt = 0;
void add(int x) {
  for (int i = 19; i >= 0; i--) {
    if (basis[i]) {
      if (x & (1 << i)) x ^= basis[i];
    } else {
      if (x & (1 << i)) {
        basis[i] = x;
        cnt++;
        return;
      }
    }
  }
}
bool check(int x) {
  for (int i = 19; i >= 0; i--) {
    if (x & (1 << i)) {
      if (basis[i])
        x ^= basis[i];
      else
        return 0;
    }
  }
  return 1;
}
signed main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  pw[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pw[i] = (pw[i - 1] * 2) % mod;
  }
  for (int i = 1; i <= q; i++) {
    int l, x;
    cin >> l >> x;
    query[l].emplace_back(x, i);
  }
  for (int i = 1; i <= n; i++) {
    add(a[i]);
    for (auto it : query[i]) {
      if (check(it.first)) ans[it.second] = pw[i - cnt];
    }
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << endl;
  return 0;
}
