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
// package arc.arc082;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int X = in.nextInt();
        int n = in.nextInt();
        long[] k = new long[n+1];
        for (int i = 0; i < n ; i++) {
            k[i] = in.nextInt();
        }
        k[n] = 1000000000 + 100;

        int q = in.nextInt();
        int[][] query = new int[q][3];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 2 ; j++) {
                query[i][j] = in.nextInt();
            }
            query[i][2] = i;
        }
        Arrays.sort(query, Comparator.comparingInt(u -> u[0]));

        long[] answer = new long[q];
        long[] min = new long[]{0, 0};
        long[] max = new long[]{X, X};

        int fr = 0;
        boolean dec = true;
        for (int i = 0; i <= n ; i++) {
            while (fr < q && query[fr][0] <= k[i]) {
                long since = query[fr][0] - (i == 0 ? 0 : k[i-1]);
                long last = 0;
                if (min[1] <= query[fr][1] && query[fr][1] <= max[1]) {
                    last = min[0] + query[fr][1] - min[1];
                } else if (query[fr][1] < min[1]) {
                    last = min[0];
                } else if (max[1] < query[fr][1]) {
                    last = max[0];
                }
                answer[query[fr][2]] = Math.max(0, Math.min(X, last + since * (dec ? -1 : 1)));
                fr++;
            }

            // upd
            long time = k[i] - (i == 0 ? 0 : k[i-1]);

            long toMin = min[0] + time * (dec ? -1 : 1);
            long toMax = max[0] + time * (dec ? -1 : 1);

            if (dec) {
                if (0 <= toMin && toMax <= X) {
                    min[0] = toMin;
                    max[0] = toMax;
                } else if (toMax >= 0) {
                    min[0] = 0;
                    max[0] = toMax;
                    min[1] += Math.abs(toMin);
                } else {
                    min[0] = max[0] = 0;
                }
            } else {
                if (0 <= toMin && toMax <= X) {
                    min[0] = toMin;
                    max[0] = toMax;
                } else if (toMin <= X) {
                    min[0] = toMin;
                    max[0] = X;
                    max[1] -= Math.abs(toMax - X);
                } else {
                    min[0] = max[0] = X;
                }
            }
            if (min[0] == max[0]) {
                min[1] = max[1] = -1;
            }
            dec = !dec;
        }

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

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

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

        private int next() {
            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 char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

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

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

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