from collections import deque

while True:

    s = eval(input())

    if s == '-': break

    else: ds = deque(s)

    ds.rotate(sum([int(eval(input())) for _ in range(int(eval(input())))])*-1)

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

    s = eval(input())

    if s == '-': break

    l = sum([int(eval(input())) for _ in range(int(eval(input())))]) % len(s)

    print((s[l:]+s[:l]))
from collections import deque

while True:
    s = eval(input())
    if s == "-":
        break
    else:
        ds = deque(s)
    ds.rotate(sum([int(eval(input())) for _ in range(int(eval(input())))]) * -1)
    print(("".join(ds)))

while True:
    s = eval(input())
    if s == "-":
        break
    l = sum([int(eval(input())) for _ in range(int(eval(input())))]) % len(s)
    print((s[l:] + s[:l]))

-from collections import deque - -    else: -        ds = deque(s) -    ds.rotate(sum([int(eval(input())) for _ in range(int(eval(input())))]) * -1) -    print(("".join(ds))) +    l = sum([int(eval(input())) for _ in range(int(eval(input())))]) % len(s) +    print((s[l:] + s[:l]))