#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin >> t;
	for(int i = 0; i < t; ++i){
	    int n, x;
	    cin >> n >> x;
	    vector<int> v(n);
	    for(int j = 0; j < n; ++j){
	        cin >> v[j];
	    }
	    int ans = 0;
	    if(is_sorted(v.begin(), v.end()))
        {
            cout << 0 << endl;
            continue;
        }
        for(int k = 0; k < n; ++k)
        {
            if(v[k] > x)
            {
                swap(x,v[k]);
                ans++;
            }
            if(is_sorted(v.begin(), v.end()))
                break;
        }
        if(!is_sorted(v.begin(), v.end()))
            ans = -1;
        cout<<ans<<endl;
	}
	return 0;
}
