while True:

    l = eval(input())

    if l == '-':

        break

    deck = list(l)

    for i in range(int(eval(input()))):

        n = int(eval(input()))

        deck = deck[n:] + deck[:n]

    print((''.join(deck)))
while True:

    deck = eval(input())

    if deck == '-':

        break

    for i in range(int(eval(input()))):

        n = int(eval(input()))

        deck = deck[n:] + deck[:n]

    print(deck)
while True:
    l = eval(input())
    if l == "-":
        break
    deck = list(l)
    for i in range(int(eval(input()))):
        n = int(eval(input()))
        deck = deck[n:] + deck[:n]
    print(("".join(deck)))

while True:
    deck = eval(input())
    if deck == "-":
        break
    for i in range(int(eval(input()))):
        n = int(eval(input()))
        deck = deck[n:] + deck[:n]
    print(deck)

-    l = eval(input()) -    if l == "-": +    deck = eval(input()) +    if deck == "-": -    deck = list(l) -    print(("".join(deck))) +    print(deck)