#include <bits/stdc++.h>
using namespace std;
long long int n, q, a[100005];
pair<pair<long long int, long long int>, long long int> qr[100005];
set<long long int> pres;
long long int val;
long long int ans[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (long long int i = 1; i <= n; ++i) cin >> a[i];
  for (long long int i = 1; i <= q; ++i) {
    cin >> qr[i].first.first >> qr[i].first.second;
    qr[i].second = i;
  }
  sort(qr + 1, qr + q + 1);
  long long int cur = 0;
  for (long long int i = 1; i <= q; ++i) {
    while (cur <= qr[i].first.first) {
      if (pres.empty()) {
        pres.insert(a[cur]);
        val = 1;
      } else if (pres.find(a[cur]) != pres.end()) {
        val = (val * 2) % 1000000007;
      } else {
        for (long long int v : pres) pres.insert(a[cur] ^ v);
      }
      cur++;
    }
    if (pres.find(qr[i].first.second) != pres.end())
      ans[qr[i].second] = val;
    else
      ans[qr[i].second] = 0;
  }
  for (long long int i = 1; i <= q; ++i) cout << ans[i] << '\n';
}
