← Home
for _ in range(int(input())):
	n,x=map(int,input().split())
	a=list(map(int,input().split()))
	if a==sorted(a):
		print(0)
		continue
	ans=0
	for i in range(n):
		if a[i]>x:
			x,a[i]=a[i],x
			ans+=1
			if a==sorted(a):
				break
	else:
		print(-1)
		continue
	print(ans)