Ehab has an array a of n integers. He likes the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and he likes to bother Mahmoud so he came up with a problem. He gave Mahmoud q queries. In each of them, he gave Mahmoud 2 integers l and x, and asked him to find the number of subsequences of the first l elements of the array such that their bitwise-xor sum is x. Can you help Mahmoud answer the queries?

A subsequence can contain elements that are not neighboring.

Input

The first line contains integers n and q (1 ≤ n, q ≤ 105), the number of elements in the array and the number of queries.

The next line contains n integers a1, a2, ..., an (0 ≤ ai < 220), the elements of the array.

The next q lines, each contains integers l and x (1 ≤ l ≤ n, 0 ≤ x < 220), representing the queries.

Output

For each query, output its answer modulo 109 + 7 in a newline.

Examples

Input

5 5
0 1 2 3 4
4 3
2 0
3 7
5 7
5 8


Output

4
2
0
4
0


Input

3 2
1 1 1
3 1
2 0


Output

4
2

Note

The bitwise-xor sum of the empty set is 0 and the bitwise-xor sum of a set containing one element is that element itself.
#include <bits/stdc++.h>
using namespace std;
inline void read(int &first) {
  register int c = getchar();
  first = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    first = (first << 1) + (first << 3) + c - 48;
  }
  if (neg) first = -first;
}
inline void read(long long &first) {
  register int c = getchar();
  first = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    first = (first << 1) + (first << 3) + c - 48;
  }
  if (neg) first = -first;
}
inline void writeln(long long first) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (first < 0) {
    neg = 1;
    first = -first;
  }
  do {
    buffor[i++] = (first % 10) + '0';
    first /= 10;
  } while (first);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
inline void write(long long first) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (first < 0) {
    neg = 1;
    first = -first;
  }
  do {
    buffor[i++] = (first % 10) + '0';
    first /= 10;
  } while (first);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar(' ');
}
const int N = 1e5 + 7;
const int LOG = 20;
const int MOD = 1e9 + 7;
int n, q, sz;
int a[N], res[N];
int basis[LOG + 5], que[N];
vector<int> qList[N];
int pw(int b) {
  if (b == 0) return 1;
  int res = pw(b / 2);
  res = (1LL * res * res) % MOD;
  if (b & 1) return (2LL * res) % MOD;
  return res;
}
bool belongToSpace(int first) {
  for (int i = LOG; i >= 0; i--)
    if ((1 << i) & first) {
      if (!basis[i]) return false;
      first ^= basis[i];
    }
  return true;
}
void add(int first) {
  for (int i = LOG; i >= 0; i--)
    if ((1 << i) & first) {
      if (!basis[i]) {
        basis[i] = first;
        sz++;
        return;
      }
      first ^= basis[i];
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (fopen("test.inp", "r"))
    freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
  read(n);
  read(q);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= q; i++) {
    int id;
    read(id);
    read(que[i]);
    qList[id].push_back(i);
  }
  for (int t = 1; t <= n; t++) {
    add(a[t]);
    for (int id : qList[t]) {
      int val = que[id];
      if (belongToSpace(val)) res[id] = pw(t - sz);
    }
  }
  for (int i = 1; i <= q; i++) writeln(res[i]);
}
