while True:

    text = eval(input())

    if text == '-':

        break



    count = int(eval(input()))

    for c in range(count):

        index = int(eval(input()))

        text = text[index:] + text[:index]



    print(text)
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:
    text = eval(input())
    if text == "-":
        break
    count = int(eval(input()))
    for c in range(count):
        index = int(eval(input()))
        text = text[index:] + text[:index]
    print(text)

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)

-    text = eval(input()) -    if text == "-": +    s = eval(input()) +    if s == "-": -    count = int(eval(input())) -    for c in range(count): -        index = int(eval(input())) -        text = text[index:] + text[:index] -    print(text) +    m = int(eval(input())) +    for mi in range(m): +        h = int(eval(input())) +        s = s[h:] + s[:h] +    print(s)