"""

"""


def game(S, A):
    res = [S[0]]
    i = 0
    while len(res) <= len(A):
        i = A[i]
        if i == 0:
            break
        res.append(S[i])
    res = "".join(res)
    return res


print(game('cdeo', [3, 2, 0, 1]))

4a02d924e534abe3ac0922d0f302d02b1229147c
<mask token>

<mask token>


def game(S, A):
    res = [S[0]]
    i = 0
    while len(res) <= len(A):
        i = A[i]
        if i == 0:
            break
        res.append(S[i])
    res = ''.join(res)
    return res


<mask token>

<mask token>


def game(S, A):
    res = [S[0]]
    i = 0
    while len(res) <= len(A):
        i = A[i]
        if i == 0:
            break
        res.append(S[i])
    res = ''.join(res)
    return res


print(game('cdeo', [3, 2, 0, 1]))

"""

"""


def game(S, A):
    res = [S[0]]
    i = 0
    while len(res) <= len(A):
        i = A[i]
        if i == 0:
            break
        res.append(S[i])
    res = "".join(res)
    return res


print(game('cdeo', [3, 2, 0, 1]))
