 #include<iostream>
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
using namespace std;

bool is_sorted(ll a[],ll n)
{
    for(ll i=1;i<n;i++)
        if(a[i]<a[i-1])
            return false;

    return true;
}

int main()
{  
     #ifndef ONLINE_JUDGE
     //for getting input from file input.txt
     freopen("input.txt","r",stdin);
    //for writing output to output.txt
     freopen("output.txt","w",stdout);
    #endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
  
 ll t,i;
 cin>>t;
 while(t--)
 { 
     ll n,i,x;
     cin>>n>>x;
     ll a[n];
     for(i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    for(i=0;i<n;i++)
    {
        if(is_sorted(a,n))
        {
            cout<<ans<<endl;
            break;
        }

        if(a[i]<=x)
            continue;
        else
            swap(a[i],x),ans++;
        
    }
    if(i==n)
    cout<<-1<<endl;

}
}
  

   
 
 