while true do
  str = gets.chomp
  break if str == "-"
  str_length = str.length
  m = gets.to_i

  m.times do
    h = gets.to_i
    str = str.slice(h..str_length) + str.slice(0...h)
  end
  puts str
end