while true
  s = gets.chomp
  break if s == "-"
  m = gets.to_i
  m.times do
    h = gets.to_i
    arr = s.split("").values_at(0..h - 1)
    s = s.split("") + arr
    h.times do
      s.delete_at(0)
    end
    s = s.join("")
  end
  puts s
end