#include #include using namespace std; int main() { int num; int top, north, east, temp; char command[10]; while(cin >> num) { if(num == 0) break; top = 1; north = 2; east = 4; for(int i=0; i> command; switch (command[0]) { case 'n': // north temp = top; top = 7 - north; north = temp; break; case 'e': // east temp = top; top = 7 - east; east = temp; break; case 'w': // west temp = top; top = east; east = 7 - temp; break; case 's': // south temp = top; top = north; north = 7 - temp; break; } } cout << top << endl; } return 0; }