import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] card = new int[n + 1]; int id = 1; int p2 = 0; int p4 = 0; int ord = 0; int idans = 1; for(int i = 0; i < m; i++) { String str = sc.next(); if(p2 > 0) { if(str.equals("drawtwo")) { } else { card[id] -= (p2 * 2); p2 = 0; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } } if(p4 > 0) { if(str.equals("drawfour")) { } else { card[id] -= (p4 * 4); p4 = 0; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } } if(str.equals("number")) { idans = id; card[id]++; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } else if(str.equals("drawtwo")) { idans = id; p2++; card[id]++; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } else if(str.equals("drawfour")) { idans = id; p4++; card[id]++; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } else if(str.equals("skip")) { idans = id; card[id]++; if(ord == 0) { if((id + 2) > n) { id = (id + 2 - n); } else { id += 2; } } else { if((id - 2) < 1) { id = n + id - 2; } else { id -= 2; } } } else { idans = id; card[id]++; ord = 1 - ord; if(ord == 0) { if((id + 1) == (n + 1)) { id = 1; } else { id++; } } else { if((id - 1) == 0) { id = n; } else { id--; } } } } System.out.println(idans + " " + card[id]); } }