n, m = map(int,input().split(' ')) num = list(map(int,input().split(' '))) num[:m] = num[:m][::-1] print(*num)