#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vlli = vector<long long int>;
using vpii = vector<pair<int, int>>;
lli N = 100020;
lli n, q, l, r, x, y, z, pos;
vlli a(N), p(N), ans(N), f(40, -1);
vector<vpii> Q(N);
void pre() {
  p[0] = 1;
  for (int i = 1; i < 100010; i++) p[i] = p[i - 1] * 2 % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pre();
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    Q[l].push_back(make_pair(r, i));
  }
  for (int i = 1; i <= n; i++) {
    x = a[i];
    pos = -1;
    for (int j = 19; j >= 0; j--) {
      if (1 << j & x) {
        if (f[j] == -1) {
          pos = j;
          break;
        } else
          x ^= f[j];
      }
    }
    if (pos == -1)
      ++z;
    else
      f[pos] = x;
    for (auto e : Q[i]) {
      y = e.first;
      for (int j = 19; j >= 0; j--) {
        if (1 << j & y) {
          if (f[j] == -1) break;
          y ^= f[j];
        }
      }
      ans[e.second] = (y == 0 ? p[z] : 0);
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
}
