#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int mod = 1e9 + 7;
int n, q, x, y;
int a[MAX];
int s[MAX];
bool m[1 << 22];
vector<int> v;
vector<pair<int, int> > g[MAX];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back({y, i});
  }
  v.push_back(0);
  m[0] = true;
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    if (m[a[i]]) {
      ans = (ans * 2) % mod;
    } else {
      vector<int> v1;
      for (int u : v) {
        v1.push_back(u ^ a[i]);
        m[u ^ a[i]] = true;
      }
      for (int u : v1) v.push_back(u);
    }
    for (auto u : g[i]) {
      if (m[u.first]) s[u.second] = ans;
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", s[i]);
  return 0;
}
