#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 2e6 + 5;
const long long mod = 1e9 + 7;
int n, q, a[N];
bool s[N];
vector<int> vs;
long long dp[N], res[N];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<tuple<int, int, int> > vq;
  for (int i = 0; i < q; i++) {
    int l, x;
    cin >> l >> x;
    vq.emplace_back(l, x, i);
  }
  sort(vq.begin(), vq.end());
  int i = 0;
  long long val = 1;
  s[0] = 1;
  vs.push_back(0);
  for (auto it : vq) {
    int l, x, id;
    tie(l, x, id) = it;
    while (i < l) {
      if (s[a[i]])
        val = (val << 1) % mod;
      else {
        vector<int> add;
        for (auto it : vs) add.push_back(it ^ a[i]);
        for (auto it : add) {
          vs.push_back(it);
          s[it] = 1;
        }
      }
      i++;
    }
    if (s[x]) res[id] = val;
  }
  for (int i = 0; i < q; i++) cout << res[i] << endl;
  return 0;
}
