#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<algorithm> #include<sstream> using namespace std; int main() { int t,i,n,k; string s,ss,s1,s2; while(cin>>t) { while(t--) { cin>>n; getchar(); while(n--) { getline(cin,s); stringstream ss(s); i=0; k=s.size(); while(ss>>s2) { reverse(s2.begin(),s2.end()); for(;i<k;i++) { if(s[i]==' ') cout<<' '; else break; } while(s[i]!=' '&&i<k) i++; cout<<s2; } cout<<endl; } if(t) cout<<endl; } } return 0; }
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<sstream>
using namespace std;
int main()
{
int t,i,n,k;
string s,ss,s1,s2;
while(cin>>t)
{
while(t--)
{ cin>>n;
getchar();
while(n--)
{ getline(cin,s);
stringstream ss(s);
i=0; k=s.size();
while(ss>>s2)
{ reverse(s2.begin(),s2.end());
for(;i<k;i++)
{ if(s[i]==' ') cout<<' ';
else break;
}
while(s[i]!=' '&&i<k) i++;
cout<<s2;
}
cout<<endl;
}
if(t) cout<<endl;
}
}
return 0;
}