func_code_string: // Author : deetav   // Happy stalking ! ^_^   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #include <bits/stdc++.h>   using namespace std;   #define endl   n       int main()   {       ios_base::sync_with_stdio(false);       cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);       int64_t t=1;       cin>>t;       while(t--)       {           int n,x;cin>>n>>x;           vector <int> lol,v;           for(int i=0,z;i<n;i++){               cin>>z;               lol.push_back(z);v.push_back(z);           }           sort(lol.begin(),lol.end());           if(lol==v){               cout<<0<<endl;continue;           }           bool sorted=false;          for(int i=0;i<n && !is_sorted(v.begin(),v.end());i++){              for(int ii=0;ii<n;ii++){                  if(v[ii]>x){                      swap(x,v[ii]);break;                  }              }              if(is_sorted(v.begin(),v.end())){                  sorted=true;                  cout<<i+1<<endl;break;              }          }          if(!sorted){              cout<<-1<<endl;          }       }       return EXIT_SUCCESS;   }