#include using namespace std; #define REP(x,y)for(ll x=0;x=0;--x) #define per(x,y,z)for(ll x=ll(z)-1;x>=ll(y);--x) #define all(v)v.begin(),v.end() #define rall(v)v.rbegin(),v.rend() #define pb emplace_back #define fi first #define se second #define lb(v,k)ll(lower_bound(all(v),k)-v.begin()) #define ub(v,k)ll(upper_bound(all(v),k)-v.begin()) #define uniq(v)sort(all(v)),v.erase(unique(all(v)),v.end()) #define sz(x)ll(x.size()) #define out(x)cout<<(x)<<'\n' #define sor(v)sort(all(v)) using ll=long long; using P=pair; using PP=tuple; using PPP=tuple; using vi=vector; using vvi=vector; using vb=vector; using vvb=vector; using vp=vector

; using vvp=vector; struct $_${$_$(){ios::sync_with_stdio(false);cin.tie(nullptr);}}$_$_$; templateinline bool chmin(T&A,S B){if(A>B){A=B;return true;}return false;} templateinline bool chmax(T&A,S B){if(Aprv; REP(i,N) { int id=lb(dp,P[i]); if(id)prv[P[i]]=dp[id-1]; dp[id]=P[i]; } vi lis; PER(i,N)if(dp[i]>N; vi P(N); REP(i,N)cin>>P[i]; auto A=minlis(P); auto B=maxlis(P); vi ans; REP(i,sz(A))if(A[i]==B[i])ans.pb(A[i]); out(sz(ans)); REP(i,sz(ans))cout<>T; while(T--) unsolve(); }