while line = gets do
  s = line.chomp
  if s == "-"
    break
  end
  m = gets.chomp.to_i
  h = []
  for i in 1..m do
    h[i-1] = gets.chomp.to_i
  end
  b = h.inject(:+) % s.size
  printf("%s\n",s[b,s.size-b] + s[0,b])
end
