#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1000000000;
int n, q, a[100005], used[2000005], cur = 1;
int result[100005];
vector<int> received;
vector<pair<int, int> > query[100005];
int main() {
  int l, x;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= q; i++) {
    cin >> l >> x;
    query[l].push_back({i, x});
  }
  received.push_back(0);
  used[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (used[a[i]]) {
      cur = (cur << 1) % mod;
    } else {
      for (int j = received.size() - 1; j > -1; j--) {
        received.push_back(received[j] ^ a[i]);
        used[received.back()] = 1;
      }
    }
    for (auto it : query[i]) result[it.first] = used[it.second] * cur;
  }
  for (int i = 1; i <= q; i++) cout << result[i] << "\n";
  cout << "\n"
       << "\n";
  return 0;
}
