#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
#define MV 20
using namespace std;
int main()
{
// READ;
// freopen("output.txt","w",stdout);
int test;
sc(test);
string str,s;
vector<string>vc;
while(test--)
{
int n;
cin>>n;
vc.clear();
getchar();
getline(cin,str);
s=str;
// cout<<str<<endl;
stringstream st;
st<<str;
bool alpha=false;
bool Hash=false;
while(st>>str)
{
if(isalpha(str[0])) alpha=true;
if(str[0]=='#') Hash=true;
vc.push_back(str);
// cout<<str<<endl;
}
int len=vc.size();
// for(int i=0;i<len;i++) cout<<vc[i]<<" ";
// cout<<endl;
if(!alpha||!Hash) cout<<s<<endl;
else
{
int index;
for(int i=0; i<len; i++)
{
string ss=vc[i];
if(isalpha(ss[0]))
{
index=i;
break;
}
}
for(int i=index+1; i<len; i++)
{
cout<<vc[i]<<" ";
}
cout<<vc[index];
for(int i=0; i<index; i++)
{
cout<<" "<<vc[i];
//if(i<index-1) cout<<" ";
}
cout<<endl;
// printf("\n");
}
}
return 0;
}
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
#define MV 20
using namespace std;
int main()
{
// READ;
// freopen("output.txt","w",stdout);
int test;
sc(test);
string str,s;
vector<string>vc;
while(test--)
{
int n;
cin>>n;
vc.clear();
getchar();
getline(cin,str);
s=str;
// cout<<str<<endl;
stringstream st;
st<<str;
bool alpha=false;
bool Hash=false;
while(st>>str)
{
if(isalpha(str[0])) alpha=true;
if(str[0]=='#') Hash=true;
vc.push_back(str);
// cout<<str<<endl;
}
int len=vc.size();
// for(int i=0;i<len;i++) cout<<vc[i]<<" ";
// cout<<endl;
if(!alpha||!Hash) cout<<s<<endl;
else
{
int index;
for(int i=0; i<len; i++)
{
string ss=vc[i];
if(isalpha(ss[0]))
{
index=i;
break;
}
}
for(int i=index+1; i<len; i++)
{
cout<<vc[i]<<" ";
}
cout<<vc[index];
for(int i=0; i<index; i++)
{
cout<<" "<<vc[i];
//if(i<index-1) cout<<" ";
}
cout<<endl;
// printf("\n");
}
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন