#include #include using namespace std; int readPosIntLn(){ int x=0; int cnt=0; int fi=-1; while(true){ char g=getchar(); if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(!(cnt>10 || ( cnt==10 && fi>1) )); } else if(g=='\n'){ return x; } else { assert(false); } } } long long readPosLongLn(){ long long x=0; int cnt=0; int fi=-1; while(true){ char g=getchar(); if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(!(cnt>19 || ( cnt==18 && fi>1) )); } else if(g=='\n'){ return x; } else { assert(false); } } } int readPosIntSpace(){ int x=0; int cnt=0; int fi=-1; while(true){ char g=getchar(); if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(!(cnt>10 || ( cnt==10 && fi>1) )); } else if(g==' '){ return x; } else { assert(false); } } } long long readPosLongSpace(){ int x=0; int cnt=0; int fi=-1; while(true){ char g=getchar(); if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(!(cnt>19 || ( cnt==18 && fi>1) )); } else if(g==' '){ return x; } else { assert(false); } } } int T; int n; int arr[11]; int dp[11]; int main(){ //cin>>T; T=readPosIntLn(); assert(1<=T && T<=30000); while(T--){ //cin>>n; n=readPosIntLn(); assert(1<=n && n<=9); for(int i=0;i>arr[i]; if(i==n-1){ arr[i]=readPosIntLn(); } else { arr[i]=readPosIntSpace(); } cout<