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;
const unsigned ELEMENT_LIMIT = 90;
const long long M = 1e9 + 7;
vector<int> sz;
vector<vector<long long> > basis;
vector<bool> is_prime(ELEMENT_LIMIT, 1);
vector<int> primes;
int BITS_LIMIT;
void precompute() {
  is_prime[0] = is_prime[1] = 1;
  for (unsigned i = 4; i <= ELEMENT_LIMIT; i += 2) is_prime[i] = 0;
  for (unsigned i = 3; i * i <= ELEMENT_LIMIT; i += 3) {
    if (is_prime[i]) {
      for (unsigned j = i * i; j <= ELEMENT_LIMIT; j += i) is_prime[j] = 0;
    }
  }
  for (unsigned i = 0; i <= ELEMENT_LIMIT; ++i) {
    if (is_prime[i]) primes.push_back(i);
  }
  BITS_LIMIT = primes.size();
}
map<int, int> pf(long long n) {
  map<int, int> res;
  for (long long i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n > 1) ++res[n];
  return res;
}
void insert_to_basis(unsigned index, long long mask) {
  vector<long long> &current_basis = basis[index];
  int &current_sz = sz[index];
  for (unsigned i = 0; i < BITS_LIMIT; ++i) {
    if (!(mask & (1LL << i))) continue;
    if (!current_basis[i]) {
      current_basis[i] = mask;
      ++current_sz;
      return;
    }
    mask ^= current_basis[i];
  }
}
bool check_if_possible(unsigned index, long long mask) {
  const vector<long long> &current_basis = basis[index];
  const int &current_sz = sz[index];
  for (unsigned i = 0; i < BITS_LIMIT; ++i) {
    if (!(mask & (1LL << i))) continue;
    if (current_basis[i])
      mask ^= current_basis[i];
    else
      return 0;
  }
  return !mask;
}
long long bin_expo(long long a, long long b, long long m) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % m;
    }
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long get_mask(long long num) {
  map<int, int> prime_f = pf(num);
  long long mask = 0;
  for (unsigned i = 0; i < BITS_LIMIT; ++i) {
    if (prime_f[primes[i]] & 1) mask = (mask | (1LL << i));
  }
  return mask;
}
long long compute_res(unsigned l, int k) {
  if (check_if_possible(l, k)) {
    return bin_expo(2, l - sz[l], M);
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  BITS_LIMIT = 20;
  unsigned n, q;
  cin >> n >> q;
  basis.resize(n + 1);
  sz.resize(n + 1);
  basis[0] = vector<long long>(BITS_LIMIT, 0);
  sz[0] = 0;
  int temp;
  for (unsigned i = 1; i <= n; ++i) {
    cin >> temp;
    basis[i] = basis[i - 1];
    sz[i] = sz[i - 1];
    insert_to_basis(i, temp);
  }
  while (q--) {
    unsigned l;
    int k;
    cin >> l >> k;
    cout << compute_res(l, k) << "\n";
  }
}
