    card = gets.chomp
    m = gets.to_i
    
    shuffle = ""
    
    m.times{
        h = gets.to_i
        shuffle = card.slice(0,h)
        card.slice!(0,h)
        card += shuffle
    }
    puts card
    
while gets != "-"
    card = $_.chomp
    shuffle = ""
    m.times{
        h = gets.to_i
        shuffle = card.slice(0..h)
        card.slice!(0..h)
        card += shuffle
    }
    puts card
end