while True:

    s=eval(input())

    if s == '-':

        break

 

 

    m=int(eval(input()))

    for mi in range(m):

        h = int(eval(input()))

        s = s[h:] + s[:h]

 

    print(s)


while True:

    z = list(map(str, eval(input())))

    if "-" in z:

        break

    n = int(eval(input()))

    for i in range(n):

        a=int(eval(input()))

        z=z[a:]+z[:a]

    print(("".join(z)))
while True:
    s = eval(input())
    if s == "-":
        break
    m = int(eval(input()))
    for mi in range(m):
        h = int(eval(input()))
        s = s[h:] + s[:h]
    print(s)

while True:
    z = list(map(str, eval(input())))
    if "-" in z:
        break
    n = int(eval(input()))
    for i in range(n):
        a = int(eval(input()))
        z = z[a:] + z[:a]
    print(("".join(z)))

-    s = eval(input()) -    if s == "-": +    z = list(map(str, eval(input()))) +    if "-" in z: -    m = int(eval(input())) -    for mi in range(m): -        h = int(eval(input())) -        s = s[h:] + s[:h] -    print(s) +    n = int(eval(input())) +    for i in range(n): +        a = int(eval(input())) +        z = z[a:] + z[:a] +    print(("".join(z)))