def shuffle(card, h)
  card.slice(h..card.length) + card.slice(0, h)
end

loop do
  card = gets.chomp
  break if card == '-'

  count = gets.chomp.to_i
  count.times do
    card = shuffle(card, gets.chomp.to_i)
  end
  puts card
end