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.
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.setIn(new FileInputStream(new File("input.txt")));
        }
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt();
            int q = inp.nextInt();
            int[] a = inp.nextArrayInt(n);
            int[] l = new int[q];
            int[] x = new int[q];
            List<Integer>[] Z = new ArrayList[n];
            for (int i = 0; i < n; ++i) {
                Z[i] = new ArrayList<>();
            }
            for (int i = 0; i < q; ++i) {
                l[i] = inp.nextInt() - 1;
                x[i] = inp.nextInt();
                Z[l[i]].add(i);
            }

            final int MOD = (int) 1e9 + 7;
            int[] dp = RandomStuff.ArrayFilled(1 << 20, 0);
            int[] mark = RandomStuff.ArrayFilled(1 << 20, 0);
            int[] ans = new int[q];
            List<Integer> S = new ArrayList<>();
            dp[0] = 1;
            mark[0] = 1;
            S.add(0);
            int coef = 1;
            for (int i = 0; i < n; ++i) {
                if (mark[a[i]] == 1) {
                    coef = coef * 2 % MOD;
                } else {
                    List<Integer> T = new ArrayList<>();
                    for (int mask: S) {
                        T.add(mask ^ a[i]);
                        dp[mask] = (int) ((long) dp[mask] * coef % MOD);
                        dp[mask ^ a[i]] = (dp[mask ^ a[i]] + dp[mask]) % MOD;
                    }
                    for (int mask: T) {
                        mark[mask] = 1;
                        S.add(mask);
                    }
                    coef = 1;
                }
                for (int t: Z[i]) {
                    ans[t] = (int) (dp[x[t]] * (long) coef % MOD);
                }
            }

            for (int i = 0; i < q; ++i) {
                out.println(ans[i]);
            }
        }
    }

    private static class RandomStuff {
        static public int[] ArrayFilled(int size, int value) {
            int[] a = new int[size];
            for (int i = 0; i < size; ++i) {
                a[i] = value;
            }
            return a;
        }
        static public int[] UnitArrayZERO(int size) {
            int[] a = new int[size];
            for (int i = 0; i < size; ++i) {
                a[i] = i;
            }
            return a;
        }
        static public int[] UnitArrayONE(int size) {
            int[] a = new int[size];
            for (int i = 0; i < size; ++i) {
                a[i] = i + 1;
            }
            return a;
        }
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextArrayInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
}