n, s, m = map(int, input().split()) s -= 1 board = list(map(int, input().split())) shadow_board = [0] * n def print_ending(ending, hops): print(ending) print(hops) exit() hops = 0 while True: if shadow_board[s] == 1: print_ending("cycle", hops) shadow_board[s] = 1 if board[s] == m: print_ending("magic", hops) if s + board[s] < 0: print_ending("left", hops + 1) if n <= s + board[s]: print_ending("right", hops + 1) s += board[s] hops += 1