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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FMahmoudAndEhabAndYetAnotherXorTask solver = new FMahmoudAndEhabAndYetAnotherXorTask();
        solver.solve(1, in, out);
        out.close();
    }

    static class FMahmoudAndEhabAndYetAnotherXorTask {
        final static long mod = (long) (1e9 + 7);

        public void solve(int testNumber, ScanReader in, PrintWriter out) {

            int n = in.scanInt();
            int q = in.scanInt();


            FMahmoudAndEhabAndYetAnotherXorTask.Basis basis = new FMahmoudAndEhabAndYetAnotherXorTask.Basis();
            ArrayList<int[]> qqq[] = new ArrayList[n + 1];
            for (int i = 0; i <= n; i++) qqq[i] = new ArrayList<>();


            int arr[] = new int[n + 1];
            for (int i = 1; i <= n; i++) arr[i] = in.scanInt();
            long res[] = new long[q];
            for (int i = 0; i < q; i++) {
                int l = in.scanInt();
                int x = in.scanInt();
                qqq[l].add(new int[]{x, i});
            }

            for (int i = 1; i <= n; i++) {
                basis.insertVector(arr[i]);
                for (int qq[] : qqq[i]) {
                    int x = qq[0];
                    int index = qq[1];
                    if (basis.checkXor(x)) res[index] = CodeX.power(2, i - basis.sz, mod);
                }
            }

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


        }

        static class Basis {
            final static int d = 27;
            int[] basis;
            int sz;

            public Basis() {
                basis = new int[d];
                this.sz = 0;
            }

            void insertVector(int mask) {
                for (int i = 0; i < d; i++) {
                    if ((mask & 1 << i) == 0) continue;
                    if (this.basis[i] == 0) {
                        this.basis[i] = mask;
                        ++this.sz;
                        return;
                    }
                    mask ^= this.basis[i];
                }
            }

            boolean checkXor(int mask) {
                for (int i = 0; i < d; i++) {
                    if ((mask & 1 << i) == 0) continue;
                    if (basis[i] == 0) return false;
                    mask ^= basis[i];
                }
                return true;
            }

        }

    }

    static class CodeX {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {

                if ((y & 1) != 0)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

