def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 K = int(input[idx]) idx += 1 A0 = list(map(int, input[idx:idx+N])) idx += N if K == 0: print(' '.join(map(str, A0))) return def next_array(current): x = current[0] m = x + 1 if m > len(current): m = len(current) rotated = current[1:m] + [current[0]] new_arr = rotated + current[m:] return new_arr seen = {} steps = [A0.copy()] seen[tuple(A0)] = 0 for step in range(1, K + 1): current = next_array(steps[step - 1]) tupled = tuple(current) if tupled in seen: start_step = seen[tupled] cycle_length = step - start_step remaining = K - start_step effective_step = (remaining % cycle_length) + start_step result = steps[effective_step] print(' '.join(map(str, result))) return else: seen[tupled] = step steps.append(current) print(' '.join(map(str, steps[K]))) if __name__ == '__main__': main()