#include <bits/stdc++.h>
const long long MAX_N = 1e6 + 5;
const long long MOD = 1e9 + 7;
using namespace std;
long long a[MAX_N];
long long dp[MAX_N];
int n, q;
map<pair<int, int>, long long> answer;
vector<int> qs[MAX_N];
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  vector<pair<int, int>> queries;
  for (int i = 0; i < q; ++i) {
    int l, x;
    cin >> l >> x;
    queries.push_back({l, x});
    qs[l].push_back(x);
  }
  dp[0]++;
  set<int> st;
  st.insert(0);
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1];
    if (st.count(a[i]))
      dp[i] += dp[i - 1];
    else {
      set<int> pm = st;
      for (auto x : pm) st.insert(x ^ a[i]);
    }
    dp[i] %= MOD;
    for (auto x : qs[i]) {
      if (!st.count(x))
        answer[{i, x}] = 0;
      else
        answer[{i, x}] = dp[i];
    }
  }
  for (auto x : queries) printf("%I64d\n", answer[x]);
  return 0;
}
