/// HuDzG
#include <bits/stdc++.h>
#define reset(a) memset(a,0,sizeof(a))
#define ll long long
#define ld long double
#define endl '\n'
#define AutoAC int main()
#define OO 1000000000000000000
#define F first
#define S second
#define pii pair <ll, ll>
#define pb push_back
#define nmax 100005
#define HUNGIT "C"
#define MOD 1000000007

using namespace std;

ll n, a[nmax], t, x;

bool check()
{
    for(int i = 1; i <= n; i++)
        if(a[i] < a[i - 1])
        {
            return 0;
        }
    return 1;
}

AutoAC
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen (HUNGIT".inp", "r", stdin);
//    freopen (HUNGIT".out", "w", stdout);
    cin >> t;
    while(t--)
    {
        cin >> n >> x;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        ll res = 0;
        if(check())
        {
            cout << 0 << endl;
            continue;
        }
        for(int i = 1; i <= n; i++)
            if(a[i] > x)
            {
                res++;
                swap(a[i], x);
                if(check()) break;
            }
        for(int i = 1; i <= n; i++)
            if(a[i] < a[i - 1])
            {
                res = -1;
                break;
            }
        cout << res << endl;
    }
    return 0;
}
