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.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

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

    static class FMahmoudAndEhabAndYetAnotherXorTaskGauss {
        int mod = 1000000007;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

            int q = in.nextInt();

            int[] a = in.nextIntArray(n);

            List<q> qs = new ArrayList<>();
            for (int i = 0; i < q; i++) {
                int l = in.nextInt() - 1;
                int x = in.nextInt();
                qs.add(new q(i, l, x));
            }

            int[] tp = new int[n + 1];

            tp[0] = 1;

            for (int i = 1; i <= n; i++) {
                tp[i] = 2 * tp[i - 1];
                tp[i] %= mod;
            }
            qs.sort((q1, q2) -> q1.l - q2.l);

            int x = 0;
            int[] fa = new int[20];
            int[] sa = new int[20];

            int[] ans = new int[q];

            int cr = 0;
            for (int i = 0; i < n; i++) {
                int num = a[i];

                int lz = Integer.numberOfLeadingZeros(num);
                for (int j = 0; j < 20; j++) {
                    if (fa[j] == 0) {
                        sa[j] = num;
                        if (num != 0)
                            cr = j + 1;
                        break;
                    } else {
                        sa[j] = fa[j];
                        int clz = Integer.numberOfLeadingZeros(fa[j]);

                        if (clz == lz) {
                            num ^= sa[j];
                            lz = Integer.numberOfLeadingZeros(num);
                        } else if (clz > lz) {
                            for (int k = j; k < 19; k++) {
                                sa[k + 1] = fa[k];
                            }
                            sa[j] = num;
                            if (num != 0)
                                cr++;
                            break;
                        }
                    }
                }

                fa = sa.clone();
                q cq;
                while (x < qs.size() && (cq = qs.get(x)).l == i) {
                    int cn = cq.x;

                    lz = Integer.numberOfLeadingZeros(cn);
                    for (int j = 0; j < 20; j++) {
                        if (fa[j] == 0) {
                            break;
                        } else {
                            int clz = Integer.numberOfLeadingZeros(fa[j]);

                            if (clz == lz) {
                                cn ^= fa[j];
                                lz = Integer.numberOfLeadingZeros(cn);
                            } else if (clz > lz) {
                                break;
                            }
                        }
                    }

                    if (cn == 0) {
                        ans[cq.qi] = tp[(i + 1) - cr];
                    }

                    x++;
                }

            }

            for (int val : ans) {
                out.println(val);
            }

        }

        class q {
            int qi;
            int l;
            int x;

            public q(int qi, int l, int x) {
                this.qi = qi;
                this.l = l;
                this.x = x;
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; ++i) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

