[Sakuzyo - Imprinting](https://www.youtube.com/watch?v=55Ca6av1kAY)

A.R.C. Markland-N is a tall building with n floors numbered from 1 to n. Between each two adjacent floors in the building, there is a staircase connecting them.

It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.

ConneR's office is at floor s of the building. On each floor (including floor s, of course), there is a restaurant offering meals. However, due to renovations being in progress, k of the restaurants are currently closed, and as a result, ConneR can't enjoy his lunch there.

CooneR wants to reach a restaurant as quickly as possible to save time. What is the minimum number of staircases he needs to walk to reach a closest currently open restaurant.

Please answer him quickly, and you might earn his praise and even enjoy the lunch with him in the elegant Neumanns' way!

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases in the test. Then the descriptions of t test cases follow.

The first line of a test case contains three integers n, s and k (2 ≤ n ≤ 10^9, 1 ≤ s ≤ n, 1 ≤ k ≤ min(n-1, 1000)) — respectively the number of floors of A.R.C. Markland-N, the floor where ConneR is in, and the number of closed restaurants.

The second line of a test case contains k distinct integers a_1, a_2, …, a_k (1 ≤ a_i ≤ n) — the floor numbers of the currently closed restaurants.

It is guaranteed that the sum of k over all test cases does not exceed 1000.

Output

For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor s to a floor with an open restaurant.

Example

Input


5
5 2 3
1 2 3
4 3 3
4 1 2
10 2 6
1 2 3 4 5 7
2 1 1
2
100 76 8
76 75 36 67 41 74 10 77


Output


2
0
4
0
2

Note

In the first example test case, the nearest floor with an open restaurant would be the floor 4.

In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.

In the third example test case, the closest open restaurant is on the 6-th floor.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rb_wahid
 */
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);
        AConneRAndTheARCMarklandN solver = new AConneRAndTheARCMarklandN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AConneRAndTheARCMarklandN {
        public static int n;
        public static int s;
        public static int k;
        public static int[] a;

        public static boolean exist(int[] arr, int x) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == x) return true;
            }
            return false;
        }

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

            while (testCase-- > 0) {
                n = in.nextInt();
                s = in.nextInt();
                k = in.nextInt();
                a = new int[k];
                for (int i = 0; i < k; i++) a[i] = in.nextInt();

                for (int i = 0; i <= k; i++) {
                    if (s - i >= 1 && !exist(a, s - i)) {
                        out.println(i);
                        break;
                    }
                    if (s + i <= n && !exist(a, s + i)) {
                        out.println(i);
                        break;
                    }
                }
                assert false;
            }
        }

    }

    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 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 static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }

    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);
        }

    }
}

