[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.
/* Rajkin Hossain */

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class A{
   
    FastInput k = new FastInput(System.in);
    FastOutput z = new FastOutput(System.out);
    Template t = new Template();
    
    void takeInputsFromFile() {
        //k = new FastInput("/home/rajkin/Desktop/input.txt");
    }
    
    void startProgram() {
    	takeInputsFromFile();
    	
    	HashSet<Integer> blocked = new HashSet<Integer>();
    	
    	int t = k.nextInt();
    	while(t-->0) {
    		int n = k.nextInt();
    		int s = k.nextInt();
    		int c = k.nextInt();
    		
    		blocked.clear();
    		
    		while(c-->0) {
    			blocked.add(k.nextInt());
    		}
    		
    		int min1 = Integer.MAX_VALUE;
    		int min2 = Integer.MAX_VALUE;
    		
    		for(int i = s; i>=1; i--) {
    			if(!blocked.contains(i)) {
    				min1 = s-i;
    				break;
    			}
    		}
    		
    		for(int i = s; i<=n; i++) {
    			if(!blocked.contains(i)) {
    				min2 = i-s;
    				break;
    			}
    		}
    		
    		z.println(min(min1, min2));
    	}
    	
    	z.close();
    	System.exit(0);
    }
    
    public static void main(String [] args) throws IOException {
        new Thread(null, new Runnable(){
            public void run(){
            	try{ 
            		new A().startProgram();
            	}
            	catch(Exception e){
            		e.printStackTrace();
            	}
            }
        },"Main",1<<28).start();
    }
    
    
    /* MARK: Template class implementation */
    
    class Template {
    	
    	//assume that a and b cannot both be 0
        int gcd(int a, int b) {
            a = Math.abs(a);
            b = Math.abs(b);
            
            while (b != 0) {
                int temp = a % b;
                a = b;
                b = temp;
            }
            
            return a;
        }
        
        long gcd(long a, long b) {
            a = Math.abs(a);
            b = Math.abs(b);
            
            while (b != 0) {
            	long temp = a % b;
                a = b;
                b = temp;
            }
            
            return a;
        }
    	
    	long lcm(long a, long b) {
    		
    		return b*a/gcd(a,b);
    	}
    	
    	int lcm(int a, int b) {
    		
    		return b*a/gcd(a,b);
    	}
    	
	    HashSet<Integer> generateSet(int [] y) {
			HashSet<Integer> set = new HashSet<Integer>();
			
			for(Integer key : y) {
				set.add(key);
			}
			
			return set;
		}
	    
	    HashSet<Long> generateSet(long [] y) {
			HashSet<Long> set = new HashSet<Long>();
			
			for(Long key : y) {
				set.add(key);
			}
			
			return set;
		}
		
		HashMap<Integer, Integer> generateCountMap(int [] y) {
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			
			for(int key : y) {
				map.putIfAbsent(key, 0);
				map.put(key, map.get(key) + 1);
			}
			
			return map;
		}
		
		HashMap<Long, Integer> generateCountMap(long [] y) {
			HashMap<Long, Integer> map = new HashMap<Long, Integer>();
			
			for(long key : y) {
				map.putIfAbsent(key, 0);
				map.put(key, map.get(key) + 1);
			}
			
			return map;
		}
		
		int [] shrink(int[] a) {
	        int n = a.length;
	        long [] b = new long[n];
	        
	        for (int i = 0; i < n; i++) b[i] = (long) a[i] << 32 | i;
	        
	        shuffleAndSort(b);
	        
	        int[] ret = new int[n];
	        int p = 0;
	        
	        for (int i = 0; i < n; i++) {
	            if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) p++;
	            ret[(int) b[i]] = p;
	        }
	 
	        for (int i = 0; i < n; i++) {
	            ret[i]++;
	        }
	        
	        return ret;
	    }
		
		long [] shrink(long [] a) {
	        int n = a.length;
	        long[] b = new long[n];
	        
	        for (int i = 0; i < n; i++) b[i] = (long) a[i] << 32 | i;
	        
	        shuffleAndSort(b);
	        
	        long [] ret = new long[n];
	        int p = 0;
	        
	        for (int i = 0; i < n; i++) {
	            if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) p++;
	            ret[(int) b[i]] = p;
	        }
	 
	        for (int i = 0; i < n; i++) {
	            ret[i]++;
	        }
	        
	        return ret;
	    }
		
		int getMax(int [] a) {
			int maxValue = Integer.MIN_VALUE;
			
			for(int v : a) {
				maxValue = max(v, maxValue);
			}
			
			return maxValue;
		}
		
		long getMax(long [] a) {
			long maxValue = Long.MIN_VALUE;
			
			for(long v : a) {
				maxValue = max(v, maxValue);
			}
			
			return maxValue;
		}
		
		int getMin(int [] a) {
			int minValue = Integer.MAX_VALUE;
			
			for(int v : a) {
				minValue = min(v, minValue);
			}
			
			return minValue;
		}
		
		long getMin(long [] a) {
			long minValue = Long.MAX_VALUE;
			
			for(long v : a) {
				minValue = min(v, minValue);
			}
			
			return minValue;
		}
		
	    void shuffleAndSort(ArrayList<Integer> a) {
	        Random rnd = new Random();
	        
	        int size = a.size();
	        
	        for (int i = size - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            int t = a.get(i);
	            a.set(i, a.get(j));
	            a.set(j, t);
	        }
	        
	        Collections.sort(a);
	    }
		
	    void shuffleAndSortLongList(ArrayList<Long> a) {
	        Random rnd = new Random();
	        
	        int size = a.size();
	        
	        for (int i = size - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            long t = a.get(i);
	            a.set(i, a.get(j));
	            a.set(j, t);
	        }
	        
	        Collections.sort(a);
	    }
		
	    void shuffleAndSort(int [] a) {
	        Random rnd = new Random();
	        
	        for (int i = a.length - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            int t = a[i];
	            a[i] = a[j];
	            a[j] = t;
	        }
	        
	        Arrays.sort(a);
	    }
	    
	    void shuffleAndSort(long [] a) {
	        Random rnd = new Random();
	        
	        for (int i = a.length - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            long t = a[i];
	            a[i] = a[j];
	            a[j] = t;
	        }
	        
	        Arrays.sort(a);
	    }
	    
		int[] getIntArray(ArrayList<Integer> list) {
			
			int [] array = new int[list.size()];
			
			int size = array.length;
			
			for(int i = 0; i<size; i++) {
				array[i] = list.get(i);
			}
			
			return array;
		}
		
		long[] getLongArray(ArrayList<Long> list) {
			
			long [] array = new long[list.size()];
			
			int size = array.length;
			
			for(int i = 0; i<size; i++) {
				array[i] = list.get(i);
			}
			
			return array;
		}
	    
        void fill2DArray(int [][] array, int value) {
        	for(int [] singleDimension : array) {
        		Arrays.fill(singleDimension, value);
        	}
        }
        
        void fill2DArray(long [][] array, long value) {
        	for(long [] singleDimension : array) {
        		Arrays.fill(singleDimension, value);
        	}
        }
        
        void fill3DArray(int [][][] array, int value) {
        	for(int [][] seconddimension : array) {
            	for(int [] singleDimension : seconddimension) {
            		Arrays.fill(singleDimension, value);
            	}
        	}
        }
        
        void fill3DArray(long [][][] array, long value) {
        	for(long [][] seconddimension : array) {
            	for(long [] singleDimension : seconddimension) {
            		Arrays.fill(singleDimension, value);
            	}
        	}
        }
        
        void fill4DArray(int [][][][] array, int value) {
        	for(int [][][] thirthdimension : array) {
            	for(int [][] seconddimension : thirthdimension) {
                	for(int [] singleDimension : seconddimension) {
                		Arrays.fill(singleDimension, value);
                	}
            	}
        	}
        }
        
        void fill4DArray(long [][][][] array, long value) {
        	for(long [][][] thirthdimension : array) {
            	for(long [][] seconddimension : thirthdimension) {
                	for(long [] singleDimension : seconddimension) {
                		Arrays.fill(singleDimension, value);
                	}
            	}
        	}
        }
    }

    
    /* MARK: FastInput and FastOutput */
 
    class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;
 
        FastInput(InputStream stream){
            reader = new BufferedReader(new InputStreamReader(stream));
        }
       
        FastInput(String path){
            try {
                reader = new BufferedReader(new FileReader(path));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            tokenizer = null;
        }
 
        String next() {
            return nextToken();
        }
       
        String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           
            return null;
        }
 
        boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }
 
        String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = null;
                try {
                    line = reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                tokenizer = new StringTokenizer(line);
            }
            return tokenizer.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(nextToken());
        }
       
        long nextLong() {
            return Long.valueOf(nextToken());
        }
        
        int [] getInputIntArray(int n) {
        	
        	int [] input = new int[n];
        	
        	for(int i = 0; i<n; i++) {
        		input[i] = nextInt();
        	}
        	
        	return input;
        }
        
        long [] getInputLongArray(int n) {
        	
        	long [] input = new long[n];
        	
        	for(int i = 0; i<n; i++) {
        		input[i] = nextLong();
        	}
        	
        	return input;
        }
        
        int [] getInputIntArrayOneBasedIndex(int n) {
        	
        	int [] input = new int[n+1];
        	
        	for(int i = 1; i<=n; i++) {
        		input[i] = nextInt();
        	}
        	
        	return input;
        }
        
        long [] getInputLongArrayOneBasedIndex(int n) {
        	
        	long [] input = new long[n+1];
        	
        	for(int i = 1; i<=n; i++) {
        		input[i] = nextLong();
        	}
        	
        	return input;
        }
    }
 
    class FastOutput {
        private final PrintWriter writer;
 
        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
 
        public FastOutput(Writer writer) {
            this.writer = new PrintWriter(writer);
        }
 
        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }
 
        public void println(Object... objects) {
            print(objects);
            writer.println();
        }
        
		public void debug(Object...obj) {
		    System.err.println(Arrays.deepToString(obj));
		}
 
        public void close() {
            writer.close();
        }
    }
}
