[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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class vac {
	
	static void swap(int n, int m){
		int temp = n;
		n = m;
		m = temp;
		
		
	}
	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 1; 
  
            // 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; 
    } 
  
	
	static int Next_greater(int a[], int n, int x) 
	{ 
	  
	    // Sort the array 
	   
	
	    int low = 0, high = n - 1, ans = x + 1; 
	  
	    // Continue until low is less 
	    // than or equals to high 
	    while (low <= high) { 
	  
	        // Find mid 
	        int mid = (low + high) / 2; 
	  
	        // If element at mid is less than 
	        // or equals to searching element 
	        if (a[mid] <= ans) { 
	  
	            // If mid is equals 
	            // to searching element 
	            if (a[mid] == ans) { 
	  
	                // Increment searching element 
	                ans++; 
	  
	                // Make high as N - 1 
	                high = n - 1; 
	            } 
	  
	            // Make low as mid + 1 
	            low = mid + 1; 
	        } 
	  
	        // Make high as mid - 1 
	        else
	            high = mid - 1; 
	    } 
	  
	    // Return the next greater element 
	    return ans; 
	} 
	public static void main(String[] args) throws IOException{
		
		
		
		Reader.init(System.in);
		int t = Reader.nextInt();
		for(int i = 0;i<t;i++) {
			int n = Reader.nextInt();
			int s = Reader.nextInt();
			int k = Reader.nextInt();
			int a[] = new int[k];
			
			for(int j = 0;j<k;j++) {
				a[j] = Reader.nextInt();
				
			}
			Arrays.sort(a);
			int e = binarySearch(a,0,k-1,s);
		
			
			if(e==-1) {
				System.out.println(0);
			}
			else {
				int h = 0;
			
			for(int j = s-1;j>=1;j--) {
				int r = binarySearch(a,0,k-1,j);
				if(r==-1){
					h = j;
					break;
				}
				
			}
			
	
			
			
			int g = Next_greater(a,k, s) ;
//			System.out.println("g="+g);
			int f = g-s;
			int w = s-h;
			
			if(g>n) {
				System.out.println(w);
			}
			else {
				
			
			if(h ==0) {
				System.out.println(f);
			}
			else {
				if(w<f) {
					System.out.println(w);
				}
				else {
					System.out.println(f);
				}
			}
			}
			}
			
			
			
			
			
			
		}
		
		
		
		
		
			
	
			
			
			
		
		
		
		
		
		
//		Reader.init(System.in);
//		int t = Reader.nextInt();
//		for(int i = 0;i<t;i++) {
//			int n = Reader.nextInt();
//			String s = Reader.next();
//			StringBuilder s8 = new StringBuilder(s);
//			TreeSet<String>  ts = new TreeSet<String>();
//			
//			for(int k = 1;k<=n;k++) {
//				int j = 0;
//				StringBuilder s1 = s8;
//				
//					String s3 = s1.substring(0,j);
//					String s4 = s1.substring(j+k,n);
////					System.out.println(s3);
////					System.out.println(s4);
//					
//				
//					
//					
//					
//				
//					StringBuilder s2 = new StringBuilder(s1.substring(j,j+k));
//					
//					s2.reverse();
//					String e3 =s2.toString();
////					System.out.println(e3);
//					String g = s3+e3+s4;
//					
//					StringBuilder q1 =new StringBuilder(g);
////					System.out.println(g);
//					s1 = q1;
//				
//					
//					
//					
//				
//				
//				String w = s1.toString()+k;
//				ts.add(w);
//			}
//			System.out.println(ts);
//
//		String z = ts.first();
//	
//		System.out.println(z.substring(0,n));
//		System.out.println(z.substring(n,z.length()));
//			
//			
//			
//		}
//		
//		
//		
//		
		}
	
		
//		Reader.init(System.in);
//		TreeSet<String> str = new TreeSet<String>(); 
//		
//			
//		int n = Reader.nextInt();
//		int m = Reader.nextInt();
//		String s1[] = new String[n];
//		
//		for(int j = 0;j<n;j++) {
//			String s = Reader.next();
//			str.add(s);
//			s1[j]=s;
//			
//		}
//		TreeSet<String> str2 = new TreeSet<String>(); 
//		
//		
//		for(int j = 0;j<n;j++)
//		{		
//			
//			StringBuilder a = new StringBuilder(s1[j]);
//			a.reverse();
//			String w = a.toString();
//			if(str.contains(w)&& !w.equals(s1[j])) {
//				StringBuilder a1 = new StringBuilder(s1[j]+w);
//				a1.reverse();
//				String f = a1.toString();
//				if(!str2.contains(w+s1[j])) {
//					str2.add(s1[j]+w);
//				}
//				}
//			}
//		
//		String a4 ="";
//		for(int j = 0;j<n;j++)
//		{		
//			
//			StringBuilder a = new StringBuilder(s1[j]);
//			a.reverse();
//			String d = a.toString();
//			if(d.equals(s1[j])) {
//				a4=s1[j];
//				break;
//				
//				
//			}
//				
//			}
//		String new1 = "";
//			
//		Iterator <String> it = str2.iterator();
//		while(it.hasNext()) {
//			new1+= it.next().substring(0,m);
//			
//		}
//		String new2 = "";
//		
//		Iterator <String> it2 = str2.descendingIterator();
//		while(it2.hasNext()) {
//			new2+= it2.next().substring(m,2*m);
//			
//		}
//		System.out.println((new1+a4+new2).length());
//		
//		System.out.println(new1+a4+new2);
		
		
		
		
		
		
				
				
	
			
			
		
		
			
			  
			
				
			
			
			
			
			
			
			
			
			
		
//			
			
		
			
		
}
	    


	


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

   
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

 
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
     
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

	