10409

#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <fstream>
#include <map>

#define INF 1000000000

using namespace std;
int T,B,W,E,S,N;
int Prev_T,Prev_N,Prev_B,Prev_S,Prev_W,Prev_E;

int main()
{
	int n;
	string cmd;

	while(cin>>n)
	{
		if(n==0)
		break;
		T=1;N=2;W=3;
		B=6;S=5;E=4;
		while(n--)
		{
			cin>>cmd;
			if(cmd=="north")
			{
				Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S;
				Prev_W=W;Prev_E=E;
				T = Prev_S; N = Prev_T;W=Prev_W;
				B = Prev_N;S=Prev_B;E=Prev_E;
			}
			else if(cmd=="south")
                        {
                                Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S;
                                Prev_W=W;Prev_E=E;
                                T = Prev_N; N = Prev_B;W=Prev_W;
                                B = Prev_S; S=Prev_T;E=Prev_E;
                        }
			else if(cmd=="east")
                        {
                                Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S;
                                Prev_W=W;Prev_E=E;
                                T = Prev_W; N = Prev_N;W=Prev_B;
                                B = Prev_E; S=Prev_S;E=Prev_T;
                        }
			else if(cmd=="west")
                        {
                                Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S;
                                Prev_W=W;Prev_E=E;
                                T = Prev_E; N = Prev_N;W=Prev_T;
                                B = Prev_W; S=Prev_S;E=Prev_B;
                        }


		}
		cout<<T<<"\n";
	}

	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *