#include #include #include using namespace std; int return_nexttop(string); int return_nextnorth(string); int return_nexteast(string); int return_nextwest(string); int return_nextbottom(string); int return_nextsouth(string); int now_top; int now_north; int now_south; int now_west; int now_east; int now_bottom; int main() { int num = 0; while(cin >> num) { if(num == 0) break; now_top = 1; now_north = 2; now_south = 5; now_west = 3; now_east = 4; now_bottom = 6; for(int i=0; i < num; i++) { string direction; cin >> direction; int temp_top,temp_north,temp_south,temp_west,temp_east,temp_bottom; temp_top = return_nexttop(direction); temp_north = return_nextnorth(direction); temp_south = return_nextsouth(direction); temp_west = return_nextwest(direction); temp_east = return_nexteast(direction); temp_bottom = return_nextbottom(direction); now_top = temp_top; now_south = temp_south; now_north = temp_north; now_west = temp_west; now_east = temp_east; now_bottom = temp_bottom; } cout << now_top << endl; } return 0; } int return_nexttop(string direction) { int next_top = now_top; if(direction == "north") next_top = now_south; if(direction == "south") next_top = now_north; if(direction == "west") next_top = now_east; if(direction == "east") next_top = now_west; return next_top; } int return_nextnorth(string direction) { int next_north = now_north; if(direction == "north") next_north = now_top; if(direction == "south") next_north = now_bottom; // if(direction == "west") ; // if(direction == "east") ; return next_north; } int return_nextsouth(string direction) { int next_south = now_south; if(direction == "north") next_south = now_bottom; if(direction == "south") next_south = now_top; // if(direction == "west") ; // if(direction == "east") ; return next_south; } int return_nexteast(string direction) { int next_east = now_east; // if(direction == "north") // if(direction == "south") if(direction == "west") next_east = now_bottom; if(direction == "east") next_east = now_top; return next_east; } int return_nextwest(string direction) { int next_west = now_west; // if(direction == "north") // if(direction == "south") if(direction == "west") next_west = now_top; if(direction == "east") next_west = now_bottom; return next_west; } int return_nextbottom(string direction) { int next_bottom = now_bottom; if(direction == "north") next_bottom = now_north; if(direction == "south") next_bottom = now_south; if(direction == "west") next_bottom = now_west; if(direction == "east") next_bottom = now_east; return next_bottom; }