#!/bin/ruby
loop = true

while loop
  line=STDIN.gets.chomp
  if line == '-'
    loop = false
    next
  end
  count=STDIN.gets.to_i
  count.times do
    pivot = STDIN.gets.to_i
    line = line[pivot..line.size-1] + line[0..pivot-1]
  end
  puts line
end