// Author : heyuhhh
// Created Time : 2020/11/30 23:19:58
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0, j; i < n; i = j) {
        bool nd = false;
        for (int k = i; k + 1 < n; k++) {
            if (a[k] > a[k + 1]) nd = true;
        }
        if (!nd) break;
        for (j = i; j < n; j++) {
            if (x < a[j]) {
                swap(x, a[j]);
                ++ans;
                break;
            }
        }
    }
    for (int i = 0; i + 1 < n; i++) {
        if (a[i] > a[i + 1]) {
            cout << -1 << '\n';
            return;
        }
    }
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    int T; cin >> T; while(T--)
    run();
    return 0;
}