/* Tue Mar 16 17:32:39 JST 2004 */ #include int top = 1, north = 2, west = 3; int main() { int i, n, _top; char s[1024]; while (1) { gets(s); n = atoi(s); if (n == 0) { break; } top = 1; north = 2; west = 3; for (i = 0; i < n; i++) { gets(s); _top = top; if (strcmp(s, "north") == 0) { top = 7 - north; north = _top; } if (strcmp(s, "south") == 0) { top = north; north = 7 - _top; } if (strcmp(s, "west") == 0) { top = 7 - west; west = _top; } if (strcmp(s, "east") == 0) { top = west; west = 7 - _top; } } printf("%d\n", top); } return 0; } /* Tue Mar 16 17:40:37 JST 2004 */