while True:

    a=eval(input())

    if a=='-':

        break

    else:

        n=int(eval(input()))

        for i in range(n):

             h=int(eval(input()))

             a=a[h:]+a[:h]

    print(a)
while True:

    a=input()

    if a=='-':

        break

    else:

        n=int(input())

        for i in range(n):

             h=int(input())

             a=a[h:]+a[:h]

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

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

-    a = eval(input()) +    a = input() -        n = int(eval(input())) +        n = int(input()) -            h = int(eval(input())) +            h = int(input())