#include<bits/stdc++.h>
using namespace std;
void solve(){
int x,y;
cin>>x>>y;
if(x<y)cout<<x<<' '<<y<<endl;
else cout<<y<<' '<<x<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin>>s;
if(s.length()==1){cout<<"NO"<<endl;return ;}
char pos=s[0];
int flag=0;
for(int i=0;i<s.length();i++){
if(s[i]!=pos){flag=1;s[0]=s[i];s[i]=pos;break;}
}
if(!flag){cout<<"NO"<<endl;return ;}
if(flag)cout<<"YES"<<endl<<s<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
void solve(){
int a,b,c,d;
int a1,a2,b1,b2;
cin>>a>>b>>c>>d;
a1=min(a,b);a2=max(a,b);b1=min(c,d);b2=max(c,d);
if(a1<b1&&b1<a2&&a2<b2)cout<<"YES"<<endl;
else if(b1<a1&a1<b2&&b2<a2)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin>>s;
bool have1=0;
int ans=0,flag=0;
for(int i=0;i<s.length();i++){
if(i>0&&s[i]=='1'&&s[i-1]=='0'){
if(flag)ans++;
else flag=1;
}
if(s[i]=='1')have1=1;
if(s[i]=='0'&&have1)have1=0,ans++;
}
cout<<ans+1<<endl;
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,k,q;
cin>>n>>k>>q;
vector<int>s(k+1),t(k+1);
s[0]=t[0]=0;
for(int i=1;i<=k;i++)cin>>s[i];
for(int i=1;i<=k;i++)cin>>t[i];
for(int i=0;i<q;i++){
int x;
cin>>x;
int l=lower_bound(s.begin(),s.end(),x)-s.begin();
if(s[l]==x)cout<<t[l];
else cout<<t[l-1]+(ll)(t[l]-t[l-1])*(x-s[l-1])/(s[l]-s[l-1]);
if(i+1==q)cout<<endl;
else cout<<' ';
}
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e7+10;
void solve(){
int r;
cin>>r;
int ans=0;
for(int i=1;i<=r;i++){
int mn=r*r-i*i;
int smn=sqrt(mn);
if(smn*smn<mn)smn++;
int mx=(r+1)*(r+1)-i*i;
int smx=sqrt(mx);
if(smx*smx>=mx)smx--;
ans+=smx-smn+1;
}
cout<<4*ans<<endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n;
cin>>n;
vector<int>a(n);
map<int,vector<int>>vis;
int mn=0;
for(int i=0;i<n;i++){
cin>>a[i];
vis[a[i]/4].push_back(a[i]);
mn=max(mn,a[i]/4);
}
for(auto &[_,i]:vis)sort(i.rbegin(),i.rend());
for(int i=0;i<n;i++){
cout<<vis[a[i]/4].back()<<' ';
vis[a[i]/4].pop_back();
}
cout<<endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin>>t;
//t=1;
while(t--)solve();
return 0;
}