$stdin = DATA if $stdin.eof?

ARGF.each do |line|
  break if line =~ /-/
  kitty = line.chomp if line =~ /[a-zA-Z]/
  count = gets.to_i if line =~ /[a-zA-Z]/
  count.times do
    at = gets.to_i
    a = kitty[0..(at-1)]
    b = kitty[at..-1]
    kitty = b + a
  end
  puts kitty
end