#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_B
while true
    cards = gets.chomp
    break if cards == '-'
    n = gets.to_i
    n.times do
        x = gets.to_i
        cards = cards[x..-1] + cards[0,x]
    end
    puts cards
end