n, k = map(int, input().split()) original = list(map(int, input().split())) current = original.copy() steps = 0 found_cycle = False cycle_length = 0 # First pass to detect cycle while steps < k: if current == original: if steps != 0: # Found a cycle cycle_length = steps remaining = k % cycle_length k = remaining found_cycle = True break a_prev = current[0] m = a_prev + 1 if m > n: m = n rotated_part = current[1:m] + [current[0]] new_current = rotated_part + current[m:] current = new_current steps += 1 # Check after incrementing steps if current == original and steps != 0: cycle_length = steps remaining = k % cycle_length k = remaining found_cycle = True break # If cycle found, reset and simulate remaining steps if found_cycle: current = original.copy() steps = 0 while steps < k: a_prev = current[0] m = a_prev + 1 if m > n: m = n rotated_part = current[1:m] + [current[0]] current = rotated_part + current[m:] steps += 1 print(' '.join(map(str, current)))