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;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const int INF = 0x3f3f3f3f;
const int MAXN = 1000005;
struct query {
  int l, x, id;
  bool operator<(const query &q) const { return l < q.l; }
} qq[MAXN];
long long ans[MAXN];
const int mod = 1e9 + 7;
struct LinearBase {
  vector<long long> base;
  bool insert(long long x) {
    for (int i = 0; i < (int)base.size(); i++) {
      x = min(x, x ^ base[i]);
    }
    if (x) base.push_back(x);
    if (x)
      return true;
    else
      return false;
  }
  bool find(long long x) {
    for (int i = 0; i < (int)base.size(); i++) {
      x = min(x, x ^ base[i]);
    }
    if (x == 0)
      return true;
    else
      return false;
  }
  long long max_element() {
    sort(base.begin(), base.end());
    long long ret = 0;
    for (int i = (int)base.size() - 1; i >= 0; i--) {
      ret = max(ret, ret ^ base[i]);
    }
    return ret;
  }
  long long min_element() {
    sort(base.begin(), base.end());
    return base[0];
  }
  long long kth_elment(int k) {
    sort(base.begin(), base.end());
    for (int i = (int)base.size() - 1; i >= 0; i--) {
      for (int j = i - 1; j >= 0; j--) {
        base[i] = min(base[i], base[i] ^ base[j]);
      }
    }
    long long ret = 0;
    if (k > (1ll << base.size())) return -1;
    int i = 0;
    while (k) {
      if (k & 1) ret ^= base[i];
      i++;
      k >>= 1;
    }
    return ret;
  }
} lb;
LinearBase merge(LinearBase x, LinearBase &y) {
  for (int i = 0; i < (int)y.base.size(); i++) {
    x.insert(y.base[i]);
  }
  return x;
}
int a[MAXN];
int k = 0, n, q;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = (1); i < (n + 1); i++) scanf("%d", a + i);
  for (int i = (1); i < (q + 1); i++) {
    scanf("%d%d", &qq[i].l, &qq[i].x);
    qq[i].id = i;
  }
  sort(qq + 1, qq + 1 + q);
  int now = 0;
  for (int i = (1); i < (q + 1); i++) {
    while (now < qq[i].l) k += !(lb.insert(a[++now]));
    if (lb.find(qq[i].x))
      ans[qq[i].id] = powmod(2, k, mod);
    else
      ans[qq[i].id] = 0;
  }
  for (int i = (1); i < (q + 1); i++) printf("%lld\n", ans[i]);
  return 0;
}
