class Uno: def __init__(self): ipt = input().split(" ") self.peoples = int(ipt[0]) self.logs = int(ipt[1]) self.position = 0 self.cards = [] self.draw2 = False self.draw2_count = 0 self.draw4 = False self.draw4_count = 0 self.reverse = False for x in range(self.peoples): self.cards.append(0) def update_pos(self): if not self.reverse: self.position += 1 if self.position == self.peoples: self.position = 0 else: self.position -= 1 if self.position == -1: self.position = self.peoples - 1 def func_number(self): self.cards[self.position] -= 1 self.update_pos() def func_reverse(self): self.cards[self.position] -= 1 if self.reverse: self.reverse = False else: self.reverse = True self.update_pos() def finalize(self): if self.reverse: self.reverse = False else: self.reverse = True self.update_pos() def func_skip(self): self.cards[self.position] -= 1 self.update_pos() self.update_pos() def func_draw2(self): self.draw2 = True self.draw2_count += 2 self.cards[self.position] -= 1 self.update_pos() def func_draw4(self): self.draw4 = True self.draw4_count += 4 self.cards[self.position] -= 1 self.update_pos() def main(self): for x in range(self.logs): char = input() if (char != "drawtwo") and self.draw2: self.cards[self.position] += self.draw2_count self.update_pos() self.draw2 = False self.draw2_count = 0 if (char != "drawfour") and self.draw4: self.cards[self.position] += self.draw4_count self.update_pos() self.draw4 = False self.draw4_count = 0 if char == "number": self.func_number() if char == "drawtwo": self.func_draw2() if char == "drawfour": self.func_draw4() if char == "skip": self.func_skip() if char == "reverse": self.func_reverse() # print(x, self.position, self.cards) self.finalize() # print("finalize: ", self.position, self.cards) print("{} {}".format(self.position + 1, abs(self.cards[self.position]))) if __name__ == "__main__": Uno().main()