#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define P 1000000007
#define inf 1e18

ll get_first(vector<ll> &v, ll x)
{
    ll i;
    for (i = 0; i < v.size(); i++)
    {
        if (v[i] > x)
            return i;
    }
    return -1;
}

int main()
{
    ll i, t;
    cin >> t;
    while (t--)
    {
        ll n, x;
        cin >> n >> x;
        vector<ll> a(n);
        for (i = 0; i < n; i++)
            cin >> a[i];
        ll ans = 0;

        while (!is_sorted(a.begin(), a.end()))
        {
            ll index = get_first(a, x);
            if (index < 0)
                break;
            swap(a[index], x);
            ans++;
        }

        if (is_sorted(a.begin(), a.end()))
            cout << ans << "\n";
        else
            cout << "-1\n";
    }

    return (0);
}
