for i in range(Q):
    td = input()
    idxes = ads[ord(td[0])-65]
    idou = idxes*golems
    golems -= idou[1:-1]
    if td[-1]=='L':
        golems += idou[:-2]
    else:
        golems += idou[2:]
print(golems[0]+golems[-1])