#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<pair<int, int>> v[100005];
int n, q, x[100005], ans[100005];
vector<int> s;
bool f[(1 << 20)];
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= q; i++) {
    int l, x;
    cin >> l >> x;
    v[l].push_back({x, i});
  }
  s.push_back(0);
  f[0] = 1;
  int nr = 1;
  for (int i = 1; i <= n; i++) {
    if (f[x[i]])
      nr = (nr * 2) % mod;
    else {
      int aux = s.size();
      for (int j = 0; j < aux; j++) {
        s.push_back(s[j] ^ x[i]);
        f[s.back()] = 1;
      }
    }
    for (int j = 0; j < v[i].size(); j++)
      ans[v[i][j].second] = nr * f[v[i][j].first];
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << "\n";
}
