def read_inputs
  data_sets = []
  loop do
    cards = gets.chomp
    break if cards == "-"
    m = gets.to_i
    shuffle_counts = (1..m).map {gets.to_i}
    data_sets << DataSet.new(cards, shuffle_counts)
  end
  data_sets
end

class DataSet
  def initialize(cards, shuffle_counts)
    @cards = cards
    @shuffle_counts = shuffle_counts
  end

  def shuffle
    @shuffle_counts.reduce(@cards.split("")) {|a, x|
      a.slice(x, a.length) + a.slice(0, x)
    }.join("")
  end
end

data_sets = read_inputs
puts data_sets.map {|ds| ds.shuffle}.join("\n")