[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.
//package com.company;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
    static void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int[n1];
        int R[] = new int[n2];

        /*Copy data to temp arrays*/
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(int arr[], int l, int r)
    {
        if (l < r) {
            // Find the middle point
            int m = (l + r) / 2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr, m + 1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
    static int binarySearch(int arr[], int l, int r, int x)
    {
        if (r >= l) {
            int mid = l + (r - l) / 2;

            // If the element is present at the
            // middle itself
            if (arr[mid] == x)
                return mid;

            // If element is smaller than mid, then
            // it can only be present in left subarray
            if (arr[mid] > x)
                return binarySearch(arr, l, mid - 1, x);

            // Else the element can only be present
            // in right subarray
            return binarySearch(arr, mid + 1, r, x);
        }

        // We reach here when element is not present
        // in array
        return -1;
    }
    public static int search(int arr[], int x)
    {
        int n = arr.length;
        for (int i = 0; i < n; i++)
        {
            if (arr[i] == x)
                return i;
        }
        return -1;
    }
    public static void main(String[] args) throws IOException {
        // write your code here
        FastReader scanner = new FastReader(System.in);
        int number = Integer.parseInt(scanner.next());

        for(int i = 0; i<number; i++) {
            int n = scanner.nextInt();
            int s = scanner.nextInt();
            int k = scanner.nextInt();
            int []close = new int[k];
//            ArrayList<Integer> close = new ArrayList<>();
            for(int j = 0; j < k; j++){
//                close.add(scanner.nextInt());
                close[j] = scanner.nextInt();
            }
            for(int j = 0; j <= k; j++){
                if(s-j >=1 && search(close,s-j) == -1){
                    out.println(j);
                    break;
                }
                if(s+j <= n && search(close,s+j) == -1){
                    out.println(j);
                    break;
                }
            }


//            sort(close,0, close.length-1);
//            int found;
//            int result = 0;
//            for(int m = 1; m <= n; m++){
//                found = binarySearch(close,0, close.length-1,m);
//                if(result != 0 && Math.abs(m-s) > result){
//                    break;
//                }
//                if(found == -1 ){
//                    result = Math.abs(m-s);
//                    if(result == 0){break;}
//                }
//            }
//            out.println(result);

        }
        out.flush();
        out.close();
    }
}