#include<iostream>
using namespace std;
const int N=1e5+5;
struct node{
int x;
int y;
}a[N];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin >> t;
while(t--){
int x,y,d;
cin >> x >> y >> d;
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i].x >> a[i].y;
}
string ans="";
for(int i=1;i<=n;i++){
int xx=a[i].x;
int yy=a[i].y;
if(d==0){
if(xx<x && yy>y){
cout << string(yy-y,'f');
cout << 'u';
cout << string(x-xx,'f');
d=3;
}
else if(xx<x && yy<y){
cout << 'u';
cout << string(x-xx,'f');
cout << 'u';
cout << string(y-yy,'f');
d=2;
}
else if(xx>x && yy>y){
cout << string(yy-y,'f');
cout << 'c';
cout << string(xx-x,'f');
d=1;
}
else if(xx>x && yy<y){
cout << 'c';
cout << string(xx-x,'f');
cout << 'c';
cout << string(y-yy,'f');
d=2;
}
}
else if(d==1){
if(xx<x && yy>y){
cout << 'u';
cout << string(yy-y,'f');
cout << 'u';
cout << string(x-xx,'f');
d=3;
}
else if(xx<x && yy<y){
cout << 'c';
cout << string(y-yy,'f');
cout << 'c';
cout << string(x-xx,'f');
d=3;
}
else if(xx>x && yy>y){
cout << string(xx-x,'f');
cout << 'u';
cout << string(yy-y,'f');
d=0;
}
else if(xx>x && yy<y){
cout << string(xx-x,'f');
cout << 'c';
cout << string(y-yy,'f');
d=2;
}
}
else if(d==2){
if(xx<x && yy>y){
cout << 'c';
cout << string(x-xx,'f');
cout << 'c';
cout << string(yy-y,'f');
d=0;
}
else if(xx<x && yy<y){
cout << string(y-yy,'f');
cout << 'c';
cout << string(x-xx,'f');
d=3;
}
else if(xx>x && yy>y){
cout << 'u';
cout << string(xx-x,'f');
cout << 'u';
cout << string(yy-y,'f');
d=0;
}
else if(xx>x && yy<y){
cout << string(y-yy,'f');
cout << 'u';
cout << string(xx-x,'f');
d=1;
}
}
else if(d==3){
if(xx<x && yy>y){
cout << string(x-xx,'f');
cout << 'c';
cout << string(yy-y,'f');
d=0;
}
else if(xx<x && yy<y){
cout << string(x-xx,'f');
cout << 'u';
cout << string(y-yy,'f');
d=2;
}
else if(xx>x && yy>y){
cout << 'c';
cout << string(yy-y,'f');
cout << 'c';
cout << string(xx-x,'f');
d=1;
}
else if(xx>x && yy<y){
cout << 'u';
cout << string(y-yy,'f');
cout << 'u';
cout << string(xx-x,'f');
d=1;
}
}
x=xx;
y=yy;
}
cout << endl;
}
return 0;
}
#include<iostream>
using namespace std;
double qpow(double a,int b){
double s=1;
for(;b;b>>=1){
if(b&1) s=s*a;
a=a*a;
}
return s;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin >> t;
while(t--){
int k;
cin >> k;
int tx,ty,x1,y1,x2,y2;
cin >> tx >> ty >> x1 >> y1 >> x2 >> y2;
double h=ty-y1;
double x=x2-x1;
double ans;
if(k>=3) ans=(4*k-10+0.5*3*qpow(0.5,k-3))*h*x*0.5;
else ans=x*h*0.5;
printf("%.3f\n",ans);
}
return 0;
}
#include<iostream>
#include<string.h>
#define int long long
typedef long long ll;
using namespace std;
const int mod=998244353;
const int N=1e5+5;
int dp[N];
int sum[N];
int ans;
signed main()
{
int t;
cin >> t;
while(t--){
string s;
cin >> s;
ans=0;
memset(sum,0,sizeof(sum));
int len=s.length();
for(int i=0;i<len;i++){
int x=s[i]-'a';
dp[i]=(dp[i-1]+2*sum[x]+i+1)%mod;
sum[x]=(sum[x]+i+1)%mod;
ans=(ans+dp[i])%mod;
}
cout << ans << endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
double tf,tr;
cin >> tf >> tr;
double x;
int la=0;
while(cin >> x){
int down=x;
int up=down+1;
double l=down+tf;
double r=down+tr;
if(x<1 && x>0){
la=1;
}
else{
if(x<l){
la=down;
}
else if(x>r){
la=up;
}
else if(abs(la-down)<abs(la-up)){
la=down;
}
else{
la=up;
}
}
cout << la << endl;
}
return 0;
}
#include<iostream>
#define int long long
typedef long long ll;
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int fact[N],infact[N];
int n,m;
int qmi(int a,int n){
int res=1;
while(n){
if(n&1) res=res*a%mod;
a=a*a%mod;
n>>=1;
}
return res%mod;
}
void init(){
fact[0]=1;
infact[0]=1;
for(int i=1;i<N;i++){
fact[i]=fact[i-1]*i%mod;
infact[i]=infact[i-1]*qmi(i,mod-2)%mod;
}
}
int calc(int a,int b){
return (fact[a]%mod*infact[b]%mod*infact[a-b]%mod)%mod;
}
void solve(){
cin >> n >> m;
int res=0;
if(n%2){
int sum=1;
for(int i=0;i<=n-1;i=i+2){
sum=(sum+calc(n,i))%mod;
}
res=qmi(sum,m);
}
else{
int sum=0;
for(int i=0;i<=n-2;i=i+2){
sum=(sum+calc(n,i))%mod;
}
res=qmi(sum,m);
for(int i=1;i<=m;i++){
res=(res+qmi(sum,i-1)*qmi(2,n*(m-i)))%mod;
}
}
cout << res << endl;
}
signed main()
{
init();
int T;
cin >> T;
while(T--) solve();
return 0;
}