m = ""

while True:

    S = eval(input())

    if S == "-":

        break



    S = list(S)

    L = S

    n = int(eval(input()))

    for i in range(n):

        m = int(eval(input()))

        for j in range(m):

            t = L.pop(0)

            L.append(t)



    L = "".join(L)

    print(L)
while True:

    card = [w for w in input()]

    if card[-1] == "-":

        break

    m = int(input())

    for i in range(m):

        h = int(input())

        for i in range(h):

            t = card[0]

            del card[0]

            card.append(t)

    for i in range(len(card)):

        print(card[i], end="")

    print()      

m = ""
while True:
    S = eval(input())
    if S == "-":
        break
    S = list(S)
    L = S
    n = int(eval(input()))
    for i in range(n):
        m = int(eval(input()))
        for j in range(m):
            t = L.pop(0)
            L.append(t)
    L = "".join(L)
    print(L)

while True:
    card = [w for w in input()]
    if card[-1] == "-":
        break
    m = int(input())
    for i in range(m):
        h = int(input())
        for i in range(h):
            t = card[0]
            del card[0]
            card.append(t)
    for i in range(len(card)):
        print(card[i], end="")
    print()

-m = "" -    S = eval(input()) -    if S == "-": +    card = [w for w in input()] +    if card[-1] == "-": -    S = list(S) -    L = S -    n = int(eval(input())) -    for i in range(n): -        m = int(eval(input())) -        for j in range(m): -            t = L.pop(0) -            L.append(t) -    L = "".join(L) -    print(L) +    m = int(input()) +    for i in range(m): +        h = int(input()) +        for i in range(h): +            t = card[0] +            del card[0] +            card.append(t) +    for i in range(len(card)): +        print(card[i], end="") +    print()