#include <bits/stdc++.h>
using namespace std;
bool add(int x, vector<int> &basis, bool insert = true) {
  int siz = basis.size();
  for (int i = siz - 1; i >= 0; --i) {
    x = min(x, x ^ basis[i]);
  }
  if (!x) return false;
  if (!insert) return true;
  basis.insert(lower_bound(basis.begin(), basis.end(), x), x);
  return true;
}
const int MOD = 1000000007;
vector<pair<int, int>> queries[100005];
int p2[100005], ans[100005], A[100005];
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (int i = 0; i < Q; ++i) {
    int l, x;
    scanf("%d%d", &l, &x);
    queries[l].push_back({x, i});
  }
  p2[0] = 1;
  for (int i = 1; i <= N; ++i) p2[i] = p2[i - 1] * 2 % MOD;
  vector<int> basis;
  for (int i = 1; i <= N; ++i) {
    add(A[i], basis);
    for (auto q : queries[i]) {
      int x = q.first;
      if (add(x, basis, false))
        ans[q.second] = 0;
      else
        ans[q.second] = p2[i - basis.size()];
    }
  }
  for (int i = 0; i < Q; ++i) printf("%d\n", ans[i]);
}
