MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = 'aabc
  3
  1
  2
  1
  vwxyz
  2
  3
  4
  -'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

s = ""
n=0
while true
  s = line[n]
  n += 1
  break if s=="-"
  line[n].to_i.times do
    n += 1
    h = line[n].to_i
    s = s[h...s.size]+s[0...h]
  end
  n += 1
  puts s
end