  #include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define el                '\n'
#define PI                3.14159265



void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,0,n)
    {
        cin>>a[i];
    }
    int cnt=0;

        cnt=0;
        int ans=0,s=0;
    rep(i,0,n)
    {
        cnt=0;
         rep(j,1,n)
        {
            if(a[j]<a[j-1])  break;

            cnt=j;
        }
        if(cnt==n-1)
        {
            cout<<ans<<el;
           return;
        }



        if(a[i]>k)
        {
           // cout<<"here"<<el;

            ans++;
            swap(a[i],k);
           
        }

    }
   cout<<-1<<el;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);


	int t=1;
	cin>>t;
	while(t--) solve();
	return 0;
}
