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 long long read() {
  long long re = 0, flag = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    re = (re << 1) + (re << 3) + ch - '0', ch = getchar();
  return re * flag;
}
struct qu {
  long long pos, num, ans, x;
} q[100010];
bool cmp1(qu l, qu r) { return l.pos < r.pos; }
bool cmp2(qu l, qu r) { return l.num < r.num; }
long long n, m, a[100010], vis[1100010], s[1100010], cnt, MOD = 1e9 + 7;
int main() {
  long long i, j, t1, t2, k, ans = 1, tmp;
  n = read();
  m = read();
  for (i = 1; i <= n; i++) a[i] = read();
  for (i = 1; i <= m; i++) {
    t1 = read();
    t2 = read();
    q[i].pos = t1;
    q[i].x = t2;
    q[i].num = i;
  }
  sort(q + 1, q + m + 1, cmp1);
  k = 1;
  vis[0] = 1;
  s[++cnt] = 0;
  for (i = 1; i <= n; i++) {
    if (vis[a[i]])
      ans = ans * 2 % MOD;
    else {
      tmp = cnt;
      for (j = 1; j <= tmp; j++) {
        s[++cnt] = s[j] ^ a[i];
        vis[s[j] ^ a[i]] = 1;
      }
    }
    while (q[k].pos == i && k <= m) q[k].ans = ans * vis[q[k].x] % MOD, k++;
  }
  sort(q + 1, q + m + 1, cmp2);
  for (i = 1; i <= m; i++) printf("%I64d\n", q[i].ans);
}
