#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::vector;
using std::swap;

int main() {
	int t;
	cin >> t;
	
	while (t--) {
		int n, x;
		cin >> n >> x;
		vector<int> a(n);
		for (auto& it : a) cin >> it;
		int cnt = 0;
		for (int i = 0; i < n && !is_sorted(a.begin(), a.end()); ++i) {
			if (a[i] > x) {
				swap(a[i], x);
				cnt++;
			}
		}
		cout << (!is_sorted(a.begin(), a.end()) ? -1 : cnt) << '\n';
	}
	
	return 0;
}
