#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int mod = 998244353, mxn = 1e5 + 1;

int solve(){
	int n, x;
	cin>> n>> x;
	int a[n];
	for(int i = 0; i < n; i++)
		cin>> a[i];
	int ans = 0;
	while(true){
		int ptr = -1;
		for(int i = 1; i < n; i++){
			if(a[i] < a[i - 1]){
				ptr = i;
				break;
			}
		}
		if(ptr == -1)
			break;
		ptr = -1;
		for(int i = 0; i < n; i++){
			if(a[i] > x){
				ptr = i;
				break;
			}
		}
		if(ptr == -1){
			return cout<< "-1\n", 0;
		}
		int tmp = a[ptr];
		a[ptr] = x;
		x = tmp;
		ans++;
	}
	cout<< ans<< "\n";
	return 0;
}

int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	cin>> t;
	while(t--) 
		solve();
	return 0;
}