样例过了
#include<bits/stdc++.h>
using namespace std;
char c;
string s;
int t,n;
int main(){
cin>>t;
while(t--){
cin>>n;
bool f=0;
string t="";
while(n--){
cin>>s;
t+=s;
for(int i=1;i<s.size();i++)if(s[i]<s[i-1]){f=1;break;}
}
for(int i=1;i<t.size();i++){
if(t[i]<t[i-1]){
f=1;
break;
}
}
if(f)cout<<0<<endl;
else cout<<1<<endl;
}
}