lines = STDIN.read.split("\n")
loop do
  cards = lines.shift
  break if cards == "-"
  n = lines.shift.to_i
  n.times do |i|
    h = lines.shift.to_i
    cards = cards[h..cards.size] + cards[0..(h - 1)]
  end
  puts cards
end