宇航员
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#define maxn 10010
using namespace std;
int a[7],temp[7];
char str[10];
void solve(int str2[],int str3[])
{
if(strcmp(str,"forward")==0)//方向不变
{
str2[0]=str3[0];
str2[1]=str3[1];
str2[2]=str3[2];
str2[3]=str3[3];
str2[4]=str3[4];
str2[5]=str3[5];
}
if(strcmp(str,"back")==0)//向后转,正,背,左,右变换
{
str2[0]=str3[1];
str2[1]=str3[0];
str2[2]=str3[3];
str2[3]=str3[2];
str2[4]=str3[4];
str2[5]=str3[5];
}
if(strcmp(str,"left")==0)//向左转,正,背,左,右变换
{
str2[0]=str3[2];
str2[1]=str3[3];
str2[2]=str3[1];
str2[3]=str3[0];
str2[4]=str3[4];
str2[5]=str3[5];
}
if(strcmp(str,"right")==0)//向右转,正,背,左,右变换
{
str2[0]=str3[3];
str2[1]=str3[2];
str2[2]=str3[0];
str2[3]=str3[1];
str2[4]=str3[4];
str2[5]=str3[5];
}
if(strcmp(str,"up")==0)//向上走,正,背,上,下变换
{
str2[0]=str3[4];
str2[1]=str3[5];
str2[2]=str3[2];
str2[3]=str3[3];
str2[4]=str3[1];
str2[5]=str3[0];
}
if(strcmp(str,"down")==0)//向下转,正,背,上,下变换
{
str2[0]=str3[5];
str2[1]=str3[4];
str2[2]=str3[2];
str2[3]=str3[3];
str2[4]=str3[0];
str2[5]=str3[1];
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int x;
temp[0]=0;//面前
temp[1]=3;//背后
temp[2]=4;//左手
temp[3]=1;//右手
temp[4]=2;//头顶
temp[5]=5;//脚下
int u=0;
int w=0;
int v=0;
int y;
while(n--)
{
scanf("%s",str);
solve(a,temp);
cin>>x;
for(int i=0; i<6; i++) temp[i]=a[i];
int y=temp[0];
if(y==0)
u+=x;
if(y==3)
u-=x;
if(y==1)
v+=x;
if(y==4)
v-=x;
if(y==2)
w+=x;
if(y==5)
w-=x;
if(n==0)
cout<<u<<" "<<v<<" "<<w<<" "<<y<<endl;
}
}
return 0;
}