while (a = gets) != "-"
  a = a.chomp.chars
  n = gets.to_i

  for i in 1..n
    s = gets.to_i
    for j in 1..s
      a.push(a.shift)
    end
  end

  (0..a.size).each { |h|
    print a[h]
  }
  puts
end