def get_dice(pips):

    return [[0, pips[4], 0, 0], 

                   [pips[3], pips[0], pips[2], pips[5]], 

                   [0, pips[1], 0, 0]]



def move_e(dice):

    dice[1] = dice[1][3:] + dice[1][:3]

    return dice



def move_n(dice):

    return [[0,          dice[1][1], 0, 0],

            [dice[1][0], dice[2][1], dice[1][2], dice[0][1]],

            [0,                 dice[1][3], 0, 0]]



def move_s(dice):

    return [[0,          dice[1][3], 0, 0],

            [dice[1][0], dice[0][1], dice[1][2], dice[2][1]],

            [0,                 dice[1][1], 0, 0]]



def move_w(dice):

    dice[1] = dice[1][1:] + dice[1][:1]

    return dice



func = {'E':move_e,'N':move_n,'S':move_s,'W':move_w}



dice = get_dice(list(map(int, input().split())))



for c in eval(input()):

    dice = func[c](dice)



print((dice[1][1]))
mask = {'N':(1, 5, 2, 3, 0, 4), 'E':(3, 1, 0, 5, 4, 2), 'S':(4, 0, 2, 3, 5, 1), 'W':(2, 1, 5, 0, 4,3)}



dice = input().split()



for c in eval(input()):

    dice = [dice[i] for i in mask[c]]



print((dice[0]))
def get_dice(pips):
    return [
        [0, pips[4], 0, 0],
        [pips[3], pips[0], pips[2], pips[5]],
        [0, pips[1], 0, 0],
    ]


def move_e(dice):
    dice[1] = dice[1][3:] + dice[1][:3]
    return dice


def move_n(dice):
    return [
        [0, dice[1][1], 0, 0],
        [dice[1][0], dice[2][1], dice[1][2], dice[0][1]],
        [0, dice[1][3], 0, 0],
    ]


def move_s(dice):
    return [
        [0, dice[1][3], 0, 0],
        [dice[1][0], dice[0][1], dice[1][2], dice[2][1]],
        [0, dice[1][1], 0, 0],
    ]


def move_w(dice):
    dice[1] = dice[1][1:] + dice[1][:1]
    return dice


func = {"E": move_e, "N": move_n, "S": move_s, "W": move_w}
dice = get_dice(list(map(int, input().split())))
for c in eval(input()):
    dice = func[c](dice)
print((dice[1][1]))

mask = {
    "N": (1, 5, 2, 3, 0, 4),
    "E": (3, 1, 0, 5, 4, 2),
    "S": (4, 0, 2, 3, 5, 1),
    "W": (2, 1, 5, 0, 4, 3),
}
dice = input().split()
for c in eval(input()):
    dice = [dice[i] for i in mask[c]]
print((dice[0]))

-def get_dice(pips): -    return [ -        [0, pips[4], 0, 0], -        [pips[3], pips[0], pips[2], pips[5]], -        [0, pips[1], 0, 0], -    ] - - -def move_e(dice): -    dice[1] = dice[1][3:] + dice[1][:3] -    return dice - - -def move_n(dice): -    return [ -        [0, dice[1][1], 0, 0], -        [dice[1][0], dice[2][1], dice[1][2], dice[0][1]], -        [0, dice[1][3], 0, 0], -    ] - - -def move_s(dice): -    return [ -        [0, dice[1][3], 0, 0], -        [dice[1][0], dice[0][1], dice[1][2], dice[2][1]], -        [0, dice[1][1], 0, 0], -    ] - - -def move_w(dice): -    dice[1] = dice[1][1:] + dice[1][:1] -    return dice - - -func = {"E": move_e, "N": move_n, "S": move_s, "W": move_w} -dice = get_dice(list(map(int, input().split()))) +mask = { +    "N": (1, 5, 2, 3, 0, 4), +    "E": (3, 1, 0, 5, 4, 2), +    "S": (4, 0, 2, 3, 5, 1), +    "W": (2, 1, 5, 0, 4, 3), +} +dice = input().split() -    dice = func[c](dice) -print((dice[1][1])) +    dice = [dice[i] for i in mask[c]] +print((dice[0]))