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;
using ld = long double;
using ul = unsigned long long;
using db = double;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using pd = pair<ld, ld>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long long>;
using vd = vector<ld>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
template <typename T, size_t size>
using va = vector<array<T, size>>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename A, typename B>
istream &operator>>(istream &in, pair<A, B> &p) {
  return in >> p.first >> p.second;
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  for (const auto &x : arr) os << x << ' ';
  return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << p.first << " " << p.second;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (auto &x : vec) {
    in >> x;
  }
  return in;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const auto &x : v) os << x << ' ';
  return os;
}
template <class T>
bool ckmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
void debug() { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
  cerr << ' ' << H;
  debug(T...);
}
long long mod = 1e9 + 7;
const long long INF = 2e18 + 6;
inline long long modPow(long long x, long long y, long long mod) {
  long long res = 1;
  x = x % mod;
  ;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % mod;
    }
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
char dirs[4] = {'R', 'D', 'L', 'U'};
unordered_map<char, int> rdirs = {{'R', 0}, {'D', 1}, {'L', 2}, {'U', 3}};
const int MXN = 1e6 + 5;
template <typename T>
struct linear_basis {
  vector<T> basis;
  vector<int> ind;
  int bits;
  int basisSize = 0;
  linear_basis(int bits) : bits(bits) {
    basis.resize(bits, -1);
    ind.resize(bits, -1);
  }
  bool add(T x, int pos = -1) {
    for (int i = bits - 1; i >= 0; --i)
      if ((x >> i) & 1) {
        if (basis[i] == -1) {
          basis[i] = x;
          basisSize++;
          ind[i] = pos;
          return true;
        }
        x ^= basis[i];
      }
    return false;
  }
  T query(long long k) {
    long long mask = 0;
    long long tot = 1LL << basisSize;
    for (int i = bits - 1; i >= 0; i--) {
      if (basis[i] != -1) {
        long long low = tot / 2;
        if ((low < k && (mask & 1 << i) == 0) ||
            (low >= k && (mask & 1 << i) > 0)) {
          mask ^= basis[i];
        }
        if (low < k) k -= low;
        tot /= 2;
      }
    }
    return mask;
  }
  bool represent(T x) {
    for (int i = bits - 1; i >= 0; --i)
      if ((x >> i) & 1) {
        if (basis[i] == -1) return false;
        x ^= basis[i];
      }
    return true;
  }
  bool represent(T x, vector<int> &res) {
    for (int i = bits - 1; i >= 0; --i)
      if ((x >> i) & 1) {
        if (basis[i] == -1) return false;
        x ^= basis[i];
        res.push_back(i);
      }
    return true;
  }
};
void solve() {
  int n, q;
  cin >> n >> q;
  vi a(n);
  cin >> a;
  linear_basis<long long> lb(20);
  vector<vpi> query(n);
  for (int i = 0; i < q; i++) {
    int l, x;
    cin >> l >> x;
    query[l - 1].push_back({x, i});
  }
  vi ans(q);
  for (int i = 0; i < n; i++) {
    lb.add(a[i]);
    for (auto j : query[i]) {
      if (lb.represent(j.first)) {
        ans[j.second] = modPow(2, i + 1 - lb.basisSize, mod);
        ans[j.second] %= mod;
      }
    }
  }
  for (auto i : ans) cout << i << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(6);
  int t = 1, tc = 1;
  while (t--) {
    solve();
    tc++;
  }
  return 0;
}
