def single_shuffle(cards, h)
  tmp = cards[0..(h-1)]
  cards.slice!(0..(h-1))
  cards<<tmp
  return cards
end

def shuffle(cards, h_array)
  length = h_array.length
  for i in 0..(length-1)
    single_shuffle(cards, h_array[i])
  end
  return cards
end

answer = []

while true
  cards = gets.chomp
  if cards == "-"
    break
  else
    m = gets.chomp.to_i
    h_array = []
    m.times do
      h = gets.chomp.to_i
      h_array.push(h)
    end
    answer.push(shuffle(cards, h_array))
  end
end

length = answer.length
for i in 0..(length-1)
  puts answer[i]
end