using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { string[] a = Console.ReadLine().Split(' '); int N = int.Parse(a[0]); int M = int.Parse(a[1]); int[] Count = Enumerable.Repeat(0, N).ToArray(); int DrawTwo = 0; int DrawFour = 0; int Reverse = 1; int Next = 0; int winner = 0; for(int i = 0;i < M; i++) { winner = Next; string s = Console.ReadLine(); if(s == "number") { if(0 < DrawTwo) { Count[Next] += DrawTwo * 2; Next += Reverse; } else if(0 < DrawFour) { Count[Next] += DrawFour * 4; Next += Reverse; } DrawTwo = 0; DrawFour = 0; Next += N; Next %= N; Count[Next]++; Next += Reverse; } else if(s == "drawtwo") { if (0 < DrawTwo) { Count[Next] += DrawFour * 4; Next += Reverse; } DrawFour = 0; Next += N; Next %= N; DrawTwo++; Count[Next]++; Next += Reverse; } else if(s == "drawfour") { if (0 < DrawTwo) { Count[Next] += DrawTwo * 2; Next += Reverse; } DrawTwo = 0; Next += N; Next %= N; DrawFour++; Count[Next]++; Next += Reverse; } else if(s == "skip") { if (0 < DrawTwo) { Count[Next] += DrawTwo * 2; Next += Reverse; } else if (0 < DrawFour) { Count[Next] += DrawFour * 4; Next += Reverse; } DrawTwo = 0; DrawFour = 0; Next += N; Next %= N; Count[Next]++; Next += Reverse * 2; } else if(s == "reverse") { if (0 < DrawTwo) { Count[Next] += DrawTwo * 2; Next += Reverse; } else if (0 < DrawFour) { Count[Next] += DrawFour * 4; Next += Reverse; } DrawTwo = 0; DrawFour = 0; Next += N; Next %= N; Count[Next]++; Reverse *= -1; Next += Reverse; } Next += N; Next %= N; } Console.WriteLine((winner + 1).ToString() + " " + Count[winner].ToString()); } }