results = []
while True:
    cards = input()
    if cards == '-':
        break
    for i in range(int(input())):
        n = int(input())
        cards = cards[n:] + cards[:n]
    results.append(cards)
for line in results:
    print(line)

d50463243dc20731a61568bd1ebaba7422105ed1
<mask token>

<mask token>
while True:
    cards = input()
    if cards == '-':
        break
    for i in range(int(input())):
        n = int(input())
        cards = cards[n:] + cards[:n]
    results.append(cards)
for line in results:
    print(line)

results = []
while True:
    cards = input()
    if cards == '-':
        break
    for i in range(int(input())):
        n = int(input())
        cards = cards[n:] + cards[:n]
    results.append(cards)
for line in results:
    print(line)
