fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().parse().ok().unwrap() } fn read_line() -> Vec { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|x| x.parse().ok().unwrap()) .collect() } fn main() { let n_m: Vec = read_line(); let mut card_counter = vec![0; n_m[0] as usize]; let mut draw_counter = vec![0; n_m[0] as usize]; let mut cur = 0; let mut stack_cnt = 0; let mut direct = 1; let mut actions: Vec = Vec::new(); for i in 0..n_m[1] { let action: String = read(); if i > 0 && (actions[(i - 1) as usize] == "drawtwo" || actions[(i - 1) as usize] == "drawfour") && action != actions[(i - 1) as usize] { draw_counter[cur as usize] += stack_cnt; cur = (cur + direct + n_m[0]) % n_m[0]; stack_cnt = 0; } card_counter[cur as usize] += 1; if action == "number" { // NOOP } else if action == "drawtwo" { stack_cnt += 2; } else if action == "drawfour" { stack_cnt += 4; } else if action == "skip" { if i < n_m[1] - 1 { cur = (cur + direct + n_m[0]) % n_m[0]; } } else if action == "reverse" { direct *= -1; } if i < n_m[1] - 1 { cur = (cur + direct + n_m[0]) % n_m[0]; } actions.push(action); } println!("{} {}", cur + 1, card_counter[cur as usize] - draw_counter[cur as usize]); }