#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20, MOD = 1000 * 1000 * 1000 + 7;
int n, q, dex, x, now, t[N], cnt[N], power[N];
bool have[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  power[0] = 1;
  for (int i = 1; i < N; i++) {
    power[i] = power[i - 1] << 1;
    if (power[i] >= MOD) power[i] -= MOD;
  }
  cin >> n >> q;
  t[0] = 1;
  have[0] = true;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (have[x]) {
      cnt[i] = now;
      continue;
    }
    cnt[i] = ++now;
    for (int j = 0; j < N; j++)
      if (have[j] == false && have[j ^ x]) {
        have[j] = true;
        t[j] = i;
      }
  }
  while (q--) {
    cin >> dex >> x;
    cout << (t[x] && t[x] <= dex ? power[dex - cnt[dex]] : 0) << '\n';
  }
  return 0;
}
