def aux(s,ops)
  while ops.length > 0
    op=ops.shift
    t=s.slice!(0,op)
    s += t
  end

  s.join
end

def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    break if ($_.chomp!)=="-"
    s = $_.split(//)
    n=fh.gets.chomp.to_i
    ops = []
    n.times {
      ops << fh.gets.chomp.to_i
    }
    puts aux(s,ops)
  end

end

if $0 == __FILE__ then
  main
end
