#include<bits/stdc++.h>
using namespace std;
int top, bottom, north, south, east, west;
void value()
{
top = 1;
bottom = 6;
east = 4;
west = 3;
north = 2;
south = 5;
}
void check(string st)
{
if(st == "north")
{
int t1 = top, b1 = bottom, s1 = south, n1 = north;
bottom = n1;
north = t1;
top = s1;
south = b1;
}
else if(st == "south")
{
int t1 = top, b1 = bottom, s1 = south, n1 = north;
north = b1;
top = n1;
south = t1;
bottom = s1;
}
else if(st == "east")
{
int e1 = east, t1 = top, w1 = west, b1 = bottom;
bottom = e1;
east = t1;
top = w1;
west = b1;
}
else if(st == "west")
{
int w1 = west, b1 = bottom, t1 = top, e1 = east;
bottom = w1;
west = t1;
top = e1;
east = b1;
}
}
int main()
{
int n, i;
while(cin >> n && n != 0)
{
string s;
value();
for(i=1;i<=n;i++)
{
cin >> s;
check(s);
}
cout << top << "\n";
}
return 0;
}
using namespace std;
int top, bottom, north, south, east, west;
void value()
{
top = 1;
bottom = 6;
east = 4;
west = 3;
north = 2;
south = 5;
}
void check(string st)
{
if(st == "north")
{
int t1 = top, b1 = bottom, s1 = south, n1 = north;
bottom = n1;
north = t1;
top = s1;
south = b1;
}
else if(st == "south")
{
int t1 = top, b1 = bottom, s1 = south, n1 = north;
north = b1;
top = n1;
south = t1;
bottom = s1;
}
else if(st == "east")
{
int e1 = east, t1 = top, w1 = west, b1 = bottom;
bottom = e1;
east = t1;
top = w1;
west = b1;
}
else if(st == "west")
{
int w1 = west, b1 = bottom, t1 = top, e1 = east;
bottom = w1;
west = t1;
top = e1;
east = b1;
}
}
int main()
{
int n, i;
while(cin >> n && n != 0)
{
string s;
value();
for(i=1;i<=n;i++)
{
cin >> s;
check(s);
}
cout << top << "\n";
}
return 0;
}
Comments
Post a Comment