[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.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger; 

public class Codechef
{
    static long fac[] = new long[1000001];
    static void perm()
    {
        fac[0]=1;
        for (int x=1;x<=1000000;x++)
        fac[x]=fac[x-1]*x;
    }
    static long power(long x, long y, long p) 
    { 
          
        // Initialize result 
        long res = 1; 
      
        // Update x if it is more than or 
        // equal to p 
        x = x % p; 
                      
        while (y > 0) 
        { 
              
            // If y is odd, multiply x 
            // with result 
            if (y % 2 == 1) 
                res = (res * x) % p; 
      
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % p; 
        } 
          
        return res; 
    } 
    // Returns n^(-1) mod p 
    static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    } 
      
    // Returns nCr % p using Fermat's 
    // little theorem. 
    static long nPr(int n, int r, 
                                    long p) 
    { 
          
        // Base case 
        if (r == 0) 
            return 1; 
      
        // Fill factorial array so that we 
        // can find all factorial of r, n 
        // and n-r 
      
        return ((fac[n] % p) * modInverse(fac[n-r], p) 
                                    % p) % p; 
    }
static long mod(String num, long a) 
    { 
          
        // Initialize result 
        long res = 0; 
  
        // One by one process all digits of 'num' 
        for (int i = 0; i < num.length(); i++) 
            res = (res * 10 + (int)num.charAt(i) 
                                     - '0') % a; 
  
        return res; 
    }
    static boolean check (int a)
    {
        String s=Integer.toString(a);
        int f[] = new int[10];
        for (int x=0;x<s.length();x++)
        {
            f[s.charAt(x)-'0']++;
            if (f[s.charAt(x)-'0']>1)
            return (false);
        }
        return (true);
    }
    static long lcm(int[] element_array) 
    { 
        long lcm_of_array_elements = 1; 
        int divisor = 2; 
          
        while (true) { 
            int counter = 0; 
            boolean divisible = false; 
              
            for (int i = 0; i < element_array.length; i++) { 
  
                // lcm_of_array_elements (n1, n2, ... 0) = 0. 
                // For negative number we convert into 
                // positive and calculate lcm_of_array_elements. 
  
                if (element_array[i] == 0) { 
                    return 0; 
                } 
                else if (element_array[i] < 0) { 
                    element_array[i] = element_array[i] * (-1); 
                } 
                if (element_array[i] == 1) { 
                    
                    
                    counter++; 
                } 
  
                // Divide element_array by devisor if complete 
                // division i.e. without remainder then replace 
                // number with quotient; used for find next factor 
                if (element_array[i] % divisor == 0) { 
                    divisible = true; 
                    element_array[i] = element_array[i] / divisor; 
                } 
            } 
  
            // If divisor able to completely divide any number 
            // from array multiply with lcm_of_array_elements 
            // and store into lcm_of_array_elements and continue 
            // to same divisor for next factor finding. 
            // else increment divisor 
            if (divisible) { 
                lcm_of_array_elements = lcm_of_array_elements * divisor; 
            } 
            else { 
                divisor++; 
            } 
  
            // Check if all element_array is 1 indicate  
            // we found all factors and terminate while loop. 
            if (counter == element_array.length) { 
                return lcm_of_array_elements; 
            } 
        } 
    }
    static boolean find(int N)
    {
        String r="";
        int rem=1%N;
        HashMap<Integer, Integer> h = new HashMap<Integer, Integer>();
        while ((rem!=0) && !h.containsKey(rem))
        {
            h.put(rem,r.length());
            rem=rem*10;
            r=r+(rem/N);
            rem=rem%N;
        }
        if (rem==0)
        return (false);
        else
        return (true);
    }
    static String sorts(String inputString) 
    { 
        // convert input string to char array 
        char tempArray[] = inputString.toCharArray(); 
          
        // sort tempArray 
        Arrays.sort(tempArray); 
          
        // return new sorted string 
        return new String(tempArray); 
    }
    static long qrt(double d)
    {
        long k=(long)(d);
        double x=-1+Math.sqrt(1+(8*d));
        x=x/2;
        long w=(long)(Math.ceil(x));
        long sum=w*(w+1);
        sum=sum/2;
        //System.out.println (w+"GDSGDS");
        while (sum%2!=k%2)
        {
            w++;
            sum=w*(w+1);
            sum=sum/2;
        }
        return (w);
    }
    static int knapSack(long W, int wt[], int val[], int n) 
     { 
        // Base Case 
    if (n <=0 || W == 0) 
        return 0; 
    if (wt[n-1] > W) 
       return knapSack(W, wt, val, n-1); 
    else 
    return Math.max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-2), knapSack(W, wt, val, n-1)); 
      } 
    static boolean index(int x, int y, int N, int M)
    {
        if (x>=0 && y>=0 && x<N && y<M)
        return (true);
        else
        return (false);
    }
    static boolean chek(int a[], int l)
    {
        int b[] = new int[l];
        int c[] = new int[l];
        b[0]=a[0];
        for (int x=1;x<l;x++)
        {
            if (b[x-1]>a[x])
            b[x]=a[x];
            else
            b[x]=b[x-1];
        }
        c[l-1]=a[l-1];
        for (int x=l-2;x>=0;x--)
        {
            if (c[x+1]<a[x])
            c[x]=a[x];
            else
            c[x]=c[x+1];
        }
        for (int x=0;x<l;x++)
        {
            if (b[x]<c[x])
            return (true);
        }
        return (false);
    }
   static ArrayList<Long> a = new ArrayList<Long>();
   static HashMap<Long, Integer> h = new HashMap<Long,Integer>();
static void factorize(long n) { 
        int count = 0; 
  
        // count the number of times 2 divides  
        while (!(n % 2 > 0)) { 
            // equivalent to n=n/2;  
            n >>= 1; 
  
            count++; 
        } 
  
        // if 2 divides it  
        if (count > 0) { 
            a.add((long)2);
            h.put((long)2,count);
        } 
  
        // check for all the possible  
        // numbers that can divide it  
        for (long i = 3; i <= (long) Math.sqrt(n); i += 2) { 
            count = 0; 
            while (n % i == 0) { 
                count++; 
                n = n / i; 
            } 
            if (count > 0) { 
                a.add(i);
                h.put(i,count); 
            } 
        } 
  
        // if n at the end is a prime number.  
        if (n > 2) { 
            a.add(n);
            h.put(n,1);
        } 
    }
    static long power(long x, int y) 
    { 
    long res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y%2==1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    Reader in = new Reader();
	    int T=in.nextInt();
	    for (int Q=1;Q<=T;Q++)
	    {
	        long N=in.nextLong();
	        long s=in.nextLong();
	        long k=in.nextLong();
	        HashMap<Long,Integer> h = new HashMap<Long,Integer>();
	        for (int x=0;x<k;x++)
	        h.put(in.nextLong(),1);
	        //long min=Integer.MAX_VALUE;\
	        long a1=Integer.MIN_VALUE,a2=Integer.MIN_VALUE;
	        for (long x=s;x<=N;x++)
	        {
	            if(!h.containsKey(x))
	            {a1=x;break;}
	        }
	        for (long x=s-1;x>=1;x--)
	        {
	            if (!h.containsKey(x))
	            {a2=x;break;}
	        }
	        System.out.println (Math.min(Math.abs(a1-s),Math.abs(a2-s)));
	    }
	}
  static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
 
        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
 
        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
 
        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }
 
        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');
 
            if (neg)
                return -ret;
            return ret;
        }
 
        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }
 
        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
 
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
 
            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }
 
            if (neg)
                return -ret;
            return ret;
        }
 
        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }
 
        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
 
        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}