#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define Inf 1000000001 int main(){ int _t; cin>>_t; rep(_,_t){ int n; cin>>n; vector p(n); rep(i,n){ cin>>p[i]; p[i]--; } bool f = true; vector a; rep(i,n){ int ind = 0; rep(j,n){ if(p[j]==i){ ind = j; break; } } while(ind!=i){ if(p[ind-1] == ind-1){ f = false; break; } int cur = ind-1; bool F = false; while(true){ if(cur==-1 || p[cur] < i){ F = true; break; } if(cur+1 == p[cur])cur--; else break; } //cout<