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 power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long a, long long p) { return power(a, p - 2, p); }
void gcd(long long a, long long b, long long& d, long long& u, long long& v) {
  if (b == 0) {
    d = a;
    u = 1;
    v = 0;
  } else {
    gcd(b, a % b, d, v, u);
    v -= a / b * u;
  }
}
long long Inverse(long long a, long long m) {
  a %= m;
  if (a < 0) a += m;
  long long d, u, v;
  gcd(a, m, d, u, v);
  assert(d == 1);
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long gcd(long long x, long long y) {
  if (x == 0 || y == 0) {
    return max(y, x);
  }
  return gcd(y % x, x);
}
long long gcdExtended(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
};
vector<pair<long long, long long> > query[100006];
int main() {
  long long n, q;
  scanf("%lld %lld", &(n), &(q));
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    a.push_back(x);
  }
  for (long long i = 0; i < q; i++) {
    long long l, x;
    scanf("%lld %lld", &(l), &(x));
    l--;
    query[l].push_back({x, i});
  }
  map<long long, long long> mapa;
  mapa[0] = 1;
  long long ans = 1;
  set<long long> s;
  s.insert(0);
  vector<long long> an(q);
  for (long long i = 0; i < n; i++) {
    if (mapa[a[i]])
      ans = (ans * 2) % 1000000007;
    else {
      for (auto p : s) {
        mapa[p ^ a[i]] = 1;
        s.insert(p ^ a[i]);
      }
    }
    for (auto p : query[i]) {
      an[p.second] = ans * mapa[p.first];
    }
  }
  for (auto p : an) cout << p << endl;
  ;
}
