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

public class Main {

    static int X;
    static int K;
    static int[] R;
    static int Q;
    static int[] T, A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        X = sc.nextInt();
        K = sc.nextInt();
        R = sc.nextIntArray(K);

        Q = sc.nextInt();
        T = new int[Q];
        A = new int[Q];
        for (int i = 0; i < Q; i++) {
            T[i] = sc.nextInt();
            A[i] = sc.nextInt();
        }

        PrintWriter pw = new PrintWriter(System.out);
        for (int l : solve()) {
            pw.println(l);
        }
        pw.flush();
    }

    static int[] solve() {

        int[] H = new int[K];
        int[] U = new int[K];
        int[] V = new int[K];

        H[0] = 0;
        U[0] = Math.min(R[0], X);
        V[0] = X;
        for (int i = 1; i < K; i++) {
            int t = R[i] - R[i-1];
            Result result;
            if( i % 2 == 0 ) {
                result = down(H[i-1], U[i-1], V[i-1], t);
            } else {
                result = up(H[i-1], U[i-1], V[i-1], t);
            }
            H[i] = result.h;
            U[i] = result.u;
            V[i] = result.v;
        }

//        for (int i = 0; i < K; i++) {
//            System.out.println( H[i] + " " + U[i] + " " + V[i]);
//        }

        int[] ans = new int[Q];
        int k = 0;
        int q = 0;

        while(q != Q && T[q] < R[0]) {
            ans[q] = calc(T[q], A[q], -1, 0, 0, 0, X);
            q++;
        }

        while(q != Q) {
            int t = T[q];
            if( k == K-1 || (R[k] <= t && t < R[k+1]) ) {
                ans[q] = calc(T[q], A[q], k, R[k], H[k], U[k], V[k]);
                q++;

            } else {
                k++;
            }
        }
        return ans;
    }

    static int calc(int t, int a, int k, int r, int h, int u, int v) {
        // rから(t-r)秒後の状態
        // kが偶数の場合上昇、奇数なら下降する
        Result result;
        if( k % 2 == 0 ) {
            result = up(h, u, v, t-r);
        } else {
            result = down(h, u, v, t-r);
        }

        return f(result.h, result.u, result.v, a);
    }

    static int f(int h, int u, int v, int a) {
        if( a <= u ) {
            return h;
        } else if( a < v ) {
            return h + (a - u);
        } else {
            return h + (v - u);
        }
    }

    static Result down(int h, int u, int v, int t) {
        int h1 = Math.max(h - t, 0);
        int v1 = v;
        int dh = h - t;
        int u1;
        if( dh > 0 ) {
            u1 = u;
        } else {
            // Uが右に動く
            u1 = Math.min(u + (-dh), v);
        }
        return new Result(h1, u1, v1);
    }

    static Result up(int h, int u, int v, int t) {
        int h1 = Math.min(h + t, X);
        int u1 = u;
        int dh = X - (h + v - u) - t;
        int v1;
        if( dh > 0 ) {
            v1 = v;

        } else {
            // Vが左に動く
            v1 = Math.max(v - (-dh), u);
        }
        return new Result(h1, u1, v1);
    }

    static class Result {
        int h, u, v;

        public Result(int h, int u, int v) {
            this.h = h;
            this.u = u;
            this.v = v;
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}
