#include // scanfとprintfを使うおまじない int nextTern(int t, int N, int isAsc) { if (isAsc == 1) { if (t == N) { t = 1; } else { t += 1; } } else { if (t == 1) { t = N; } else { t -= 1; } } return t; } int main(int argc, char *argv[]){ int N, M, i; char S[11]; char buf[1024]; int whosTern = 1; int isAsc = 0; int drowTwoCnt = 0; int drowFourCnt = 0; fgets(buf, sizeof(buf), stdin); sscanf(buf, "%d%d", &N, &M); int hands[N]; for (i=0; i 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; } else if (S == "skip") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; nextTern(whosTern, N, isAsc); } else if (S == "reverse") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } else if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; if (isAsc == 0) { isAsc = 1; } else { isAsc = 0; } } else if (S == "drawtwo") { if (drowFourCnt > 0) { hands[whosTern-1] -= 4*drowFourCnt; nextTern(whosTern, N, isAsc); drowFourCnt = 0; } hands[whosTern-1] += 1; drowTwoCnt += 1; } else if (S == "drawfour") { if (drowTwoCnt > 0) { hands[whosTern-1] -= 2*drowTwoCnt; nextTern(whosTern, N, isAsc); drowTwoCnt = 0; } hands[whosTern-1] += 1; drowFourCnt += 1; } } // 標準出力に出力 printf("%d %d\n", whosTern, hands[whosTern-1]); return 0; }