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;
template <class T, size_t n>
ostream &operator<<(ostream &os, array<T, n> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, set<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class K, class X>
ostream &operator<<(ostream &os, map<K, X> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
using ii = pair<long long, long long>;
using vb = vector<bool>;
using vi = vector<long long>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;
class gauss {
  vi basis;

 public:
  void add(long long x) {
    for (long long b : basis) x = min(x, x ^ b);
    for (long long &b : basis) b = min(b, x ^ b);
    if (x > 0) {
      basis.push_back(x);
    }
  }
  bool can(long long x) const {
    for (long long b : basis) x = min(x, x ^ b);
    return (x == 0);
  }
  long long rank() const { return basis.size(); }
  long long maximum() const {
    long long ans = 0;
    for (long long b : basis) ans ^= b;
    return ans;
  }
};
const long long mod = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  vector<long long> po2 = {1};
  for (long long i = 0; i < n; i++) {
    po2.push_back((po2.back() * 2) % mod);
  }
  vector<gauss> g(n);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (i > 0) g[i] = g[i - 1];
    g[i].add(x);
  }
  for (long long i = 0; i < q; i++) {
    long long l, x;
    cin >> l >> x;
    l--;
    if (g[l].can(x)) {
      long long ans = l + 1 - g[l].rank();
      cout << po2[ans] << '\n';
      continue;
    }
    cout << 0 << '\n';
  }
}
