import sys

with open(sys.argv[1], 'r') as test_cases:
    for test in test_cases:
        if (test != None):
            list = test.split("|")
            scrammbled_message = list[0]
            temp = test[(test.find("|") + 1):]
            indicies = temp.split()
            message = ""
            for index in indicies:
                message = message + scrammbled_message[int(index) - 1]
            print(message)