while true do
   string = gets.chomp
   break if string == "-"
   count = gets.chomp.to_i
   i = 0
   while true do
      break if i == count
      shuffle_num = gets.chomp.to_i
      partial = string.slice!(0, shuffle_num)
      string = string + partial
      i += 1
   end
   puts string
end