We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb.

The sand drops from the upper bulb to the lower bulb at a rate of 1 gram per second. When the upper bulb no longer contains any sand, nothing happens.

Initially at time 0, bulb A is the upper bulb and contains a grams of sand; bulb B contains X-a grams of sand (for a total of X grams).

We will turn over the sandglass at time r_1,r_2,..,r_K. Assume that this is an instantaneous action and takes no time. Here, time t refer to the time t seconds after time 0.

You are given Q queries. Each query is in the form of (t_i,a_i). For each query, assume that a=a_i and find the amount of sand that would be contained in bulb A at time t_i.

Constraints

* 1≤X≤10^9
* 1≤K≤10^5
* 1≤r_1<r_2< .. <r_K≤10^9
* 1≤Q≤10^5
* 0≤t_1<t_2< .. <t_Q≤10^9
* 0≤a_i≤X (1≤i≤Q)
* All input values are integers.

Input

The input is given from Standard Input in the following format:


X
K
r_1 r_2 .. r_K
Q
t_1 a_1
t_2 a_2
:
t_Q a_Q


Output

For each query, print the answer in its own line.

Examples

Input

180
3
60 120 180
3
30 90
61 1
180 180


Output

60
1
120


Input

100
1
100000
4
0 100
90 100
100 100
101 100


Output

100
10
0
0


Input

100
5
48 141 231 314 425
7
0 19
50 98
143 30
231 55
342 0
365 100
600 10


Output

19
52
91
10
58
42
100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.List;
import java.io.BufferedReader;
import java.util.Comparator;
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;
        MyInput in = new MyInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static @SuppressWarnings("unchecked")
    class TaskF {
        int X;
        int K;
        int Q;
        int[] r;
        int[][] qs;

        public void solve(int testNumber, MyInput in, PrintWriter out) {
            X = in.nextInt();
            K = in.nextInt();
            r = new int[K + 1];
            System.arraycopy(in.nextIntArray(K), 0, r, 0, K);
            r[K] = Integer.MAX_VALUE;
            Q = in.nextInt();
            qs = in.nextIntArray2DWithIndex(Q, 2);
            Arrays.sort(qs, Comparator.comparingInt(a -> a[1]));
            for (int i = 0; i < Q; i++) {
                qs[i][2] = i;
            }
            Bucket.X = X;
            Buckets buckets = new Buckets(Q, (l, r) -> {
                int[] v = new int[r - l];
                for (int i = l; i < r; i++) v[i - l] = qs[i][1];
                return new Bucket(l, r, v);
            });

            int[] ans = new int[Q];
            Arrays.sort(qs, Comparator.comparingInt(a -> a[0]));
            for (int i = 0, j = 0; i <= K && j < Q; i++) {
                final int sign = i % 2 == 0 ? -1 : 1;
                for (; j < Q && qs[j][0] < r[i]; j++) {
                    final int dt = qs[j][0] - (i == 0 ? 0 : r[i - 1]);
                    final int idx = qs[j][2];
                    ans[j] = buckets.get(idx, b -> b.get(idx, sign * dt));
                }
                final int dt = r[i] - (i == 0 ? 0 : r[i - 1]);
                final int v = sign * dt;
                buckets.foreach(b -> b.update(v));
            }
            for (int a : ans) out.println(a);
        }

    }

    static class Bucket {
        public final int l;
        public final int r;
        static int X;
        public int set;
        public int add;
        public int[] value;

        public void update(int d) {
            int lv = get(l, d);
            int rv = get(r - 1, d);
            if (rv <= 0) {
                set = 0;
                add = 0;
                return;
            }
            if (lv >= X) {
                set = X;
                add = 0;
                return;
            }
            if (lv > 0 && rv < X) {
                add += d;
                return;
            }
            for (int i = 0; i < value.length; i++) {
                value[i] = Math.max(0, Math.min(value[i] + add + d, X));
            }
            add = 0;
        }

        public int get(int i, int d) {
            int v = set == -1 ? value[i - l] : set;
            return Math.max(0, Math.min(v + add + d, X));
        }

        public Bucket(int l, int r, int[] v) {
            this.l = l;
            this.r = r;
            this.set = -1;
            this.value = v;
        }

    }

    static interface BucketAccessor<U> {
        U access(Bucket bucket);

    }

    static interface BucketSupplier {
        Bucket supply(int l, int r);

    }

    static class MyInput {
        private final BufferedReader in;
        private static int pos;
        private static int readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static char[] str = new char[500 * 8 * 2];
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];
        private static boolean[] isLineSep = new boolean[256];

        static {
            for (int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
            isLineSep['\r'] = isLineSep['\n'] = true;
        }

        public MyInput(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
        }

        public int read() {
            if (pos >= readLen) {
                pos = 0;
                try {
                    readLen = in.read(buffer);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (readLen <= 0) {
                    throw new MyInput.EndOfFileRuntimeException();
                }
            }
            return buffer[pos++];
        }

        public int nextInt() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            int i = 0;
            int ret = 0;
            if (str[0] == '-') {
                i = 1;
            }
            for (; i < len; i++) ret = ret * 10 + str[i] - '0';
            if (str[0] == '-') {
                ret = -ret;
            }
            return ret;
        }

        public char nextChar() {
            while (true) {
                final int c = read();
                if (!isSpace[c]) {
                    return (char) c;
                }
            }
        }

        int reads(int len, boolean[] accept) {
            try {
                while (true) {
                    final int c = read();
                    if (accept[c]) {
                        break;
                    }
                    if (str.length == len) {
                        char[] rep = new char[str.length * 3 / 2];
                        System.arraycopy(str, 0, rep, 0, str.length);
                        str = rep;
                    }
                    str[len++] = (char) c;
                }
            } catch (MyInput.EndOfFileRuntimeException e) {
            }
            return len;
        }

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

        public int[][] nextIntArray2DWithIndex(final int n, final int k) {
            final int[][] res = new int[n][k + 1];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < k; j++) {
                    res[i][j] = nextInt();
                }
                res[i][k] = i;
            }
            return res;
        }

        static class EndOfFileRuntimeException extends RuntimeException {
        }

    }

    static class Buckets {
        List<Bucket> buckets;
        int B;
        int S;
        int n;

        public Buckets(int n, BucketSupplier supplier) {
            this.n = n;
            S = (int) Math.sqrt(n);
            B = (n + S - 1) / S;
            buckets = new ArrayList<>(B);
            for (int i = 0; i < B; i++) {
                int l = i * S;
                int r = Math.min((i + 1) * S, n);
                buckets.add(supplier.supply(l, r));
            }
        }

        public <U> U get(int idx, BucketAccessor<U> f) {
            return f.access(buckets.get(idx / S));
        }

        public void foreach(Consumer<Bucket> consumer) {
            buckets.forEach(consumer);
        }

    }
}

