def lscan; gets.split.map(&:to_i); end n, k = lscan S = gets.chomp # s = S # (n-k+1).times do |i| # x,y,z = s[0...i], s[i...(i+k)], s[(i+k)..-1] # s = x + y.reverse + z # p s # end # puts s head, tail = S[0...(k-1)], S[(k-1)..-1] head.reverse! if k.odd? puts tail + head