#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
const int maxn = 100010, mod = 1000000007;
int n, q, ans = 1, a[maxn], res[maxn];
bool appear[1 << 20];
vector<pair<int, int> > G[maxn];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1, l, x; i <= q; ++i) {
    scanf("%d%d", &l, &x);
    G[l].push_back(make_pair(x, i));
  }
  appear[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (!appear[a[i]])
      for (int j = 0; j < 1 << 20; ++j) appear[j] |= appear[j ^ a[i]];
    else
      ans = (ans * 2) % mod;
    for (int j = 0; j < G[i].size(); ++j)
      if (appear[G[i][j].first]) res[G[i][j].second] = ans;
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", res[i]);
}
