#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const double eps = 1e-9;
int A[N][N], x[N];
int free_x[N], cnt = 0;
int Gauss(int equ, int var) {
  int row = 0, col = 0;
  cnt = 0;
  for (int i = 0; i <= var; i++) x[i] = free_x[i] = 0;
  for (row = 0, col = 0; row < equ && col < var; row++, col++) {
    int M_id = row;
    for (int i = row + 1; i < equ; i++)
      if (abs(A[i][col]) > abs(A[M_id][col])) M_id = i;
    if (abs(A[M_id][col]) < eps) {
      free_x[cnt++] = col;
      row--;
      continue;
    }
    for (int i = 0; i <= var; i++) swap(A[M_id][i], A[row][i]);
    for (int i = row + 1; i < equ; i++) {
      if (A[i][col] == 1)
        for (int j = col; j <= var; j++) A[i][j] ^= A[row][j];
    }
  }
  for (int i = row; i < equ; i++)
    if (A[i][var] == 1) return -1;
  if (row < var) return var - row;
  for (int i = row - 1; i > -1; i--) {
    x[i] ^= A[i][var];
    for (int j = i + 1; j < var; j++) x[i] ^= (A[i][j] && x[j]);
  }
  return 0;
}
void enum_free() {}
int S[N][N], w = 30;
void Copy(int No, int (*Des)[N], int (*Res)[N]) {
  for (int i = 0; i < w; i++) Des[No][i] = Res[No][i];
}
const int NN = 1e5 + 10;
const long long MOD = 1e9 + 7;
int ans[NN];
int flag[35];
int main() {
  int n, q, equ = 0;
  scanf("%d%d", &n, &q);
  long long sum = 1;
  for (int i = 0; i <= n; i++) ans[i] = sum, sum = sum * 2 % MOD;
  for (int i = 0; i < n; i++) {
    int x = 0;
    scanf("%d", &x);
    int p = x, c = 0;
    for (int i = 0; i < w; i++) S[equ][i] = A[equ][i] = 0;
    while (p > 0) {
      if (p & 1) S[equ][c] = A[equ][c] = 1;
      c++;
      p >>= 1;
    }
    int res = Gauss(equ + 1, w);
    if (res + equ + 1 == w) flag[++equ] = i + 1;
  }
  for (int i = 0; i < equ; i++) Copy(i, A, S);
  for (int i = 0; i < q; i++) {
    int l, x;
    scanf("%d%d", &l, &x);
    int u = 0, p = x, c = 0;
    while (flag[u] <= l && u <= equ) u++;
    u--;
    for (int i = 0; i < w; i++) A[u][i] = 0;
    while (p > 0) {
      if (p & 1) A[u][c] = 1;
      c++;
      p >>= 1;
    }
    if (Gauss(u + 1, w) + u + 1 == w)
      cout << 0 << '\n';
    else
      cout << ans[l - u] << '\n';
    for (int i = 0; i <= u; i++) Copy(i, A, S);
  }
}
