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>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
                     "no-stack-protector")
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
namespace SOLVE {
void main() {}
}  // namespace SOLVE
long long fast(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      b--;
      ans = ans * a % mod;
    } else {
      a = a * a % mod;
      b /= 2;
    }
  }
  return ans % mod;
}
struct base {
  long long base[20];
  long long zero;
  void add(long long c) {
    for (long long i = 19; i >= 0; i--) {
      if (twop(i) & c) {
        if (base[i])
          c ^= base[i];
        else {
          base[i] = c;
          return;
        }
      }
    }
    zero++;
  }
  long long query(long long c) {
    for (long long i = 19; i >= 0; i--) {
      if (twop(i) & c) {
        if (base[i])
          c ^= base[i];
        else {
          return 0;
        }
      }
    }
    return fast(2, zero, mod);
  }
};
base b[100010];
int n, q;
int main() {
  in(n, q);
  for (long long i = 1; i < n + 1; i++) {
    int c;
    in(c);
    b[i] = b[i - 1];
    b[i].add(c);
  }
  for (long long i = 0; i < q; i++) {
    int l, x;
    in(l, x);
    cout << b[l].query(x) << endl;
  }
  SOLVE::main();
  return 0;
}
