#include<iostream>
using namespace std;
int main()
{
    int t,n,x,a[502],b,c,d,f=1,count;
    cin>>t;
    while (t--)
    {
        count=0;
        d=1;
        cin>>n>>x;
        for(b=1;b<=n;b++)
        {
            cin>>a[b];
        }
        re:
        for(b=1;b<n;b++)
        {
            if(a[b]>a[b+1])
            goto wrong;
        }
        goto done;
        wrong:
        for(b=1;b<=n;b++)
        {
            if(a[b]>x)
            {
                c=x;x=a[b];a[b]=c;
                if(b!=n)
                count++;
                goto re;
            }
        }
        for(b=1;b<n;b++)
        {
            for(c=b+1;c<=n;c++)
            {
                if(a[b]>a[c])
                {d=0;}
            }
        }
        done:
        if(d==1)
        cout<<count<<"\n";
        if (d==0)
        cout<<"-1"<<"\n";
    }
}