#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:536870912")
#pragma warning(disable : 4996)
using namespace std;
const int N = 1 << 21, mod = 1e9 + 7;
int a[N], ans[N], inSet[N];
pair<pair<int, int>, int> g[N];
vector<int> v;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  inSet[0] = 1;
  v.push_back(0);
  for (int i = 0; i < q; i++) {
    int l, x;
    scanf("%d%d", &l, &x);
    g[i] = {{l, x}, i};
  }
  sort(g, g + q);
  int t = 0, w = 1;
  for (int i = 0; i < q; i++) {
    for (; t < g[i].first.first; t++) {
      if (inSet[a[t]]) {
        w *= 2;
        if (w >= mod) w -= mod;
      } else {
        inSet[a[t]] = 1;
        for (int i = v.size() - 1; i >= 0; i--) {
          v.push_back(v[i] ^ a[t]);
          inSet[v.back()] = 1;
        }
      }
    }
    if (inSet[g[i].first.second]) ans[g[i].second] = w;
  }
  for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
  return 0;
}
