Problem:
Dice I Write a program to simulate rolling a dice, which can be constructed by the following net.    As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of ' E ', ' N ', ' S ' and ' W ' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Constraints  $0 \leq $ the integer assigned to a face $ \leq 100$  $0 \leq $ the length of the command $\leq 100$  Sample Input 1 1 2 4 8 16 32
SE Sample Output 1 8 You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E , you can see 8 on the top face. Sample Input 2 1 2 4 8 16 32
EESWN Sample Output 2 32

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
   
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):
dice = list(map(int, input().split()))
slist = input()
 
for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")
 
    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]
 
    dice = tmp
 
print(dice[0])

Solution (Python):
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 

class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
 
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def get_Top(self):
        return self.number[0]
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)
 
print("%d"%(dice.get_Top()))

Solution (Python):
class Dice:
    def __init__(self, num, dire):
        self.num = num
        self.dir = dire

    def rotate(self):
        for hou in self.dir:
            if hou == "S":
                self.num[0], self.num[4], self.num[5], self.num[1] = self.num[4], self.num[5], self.num[1], self.num[0]
                tile = self.num[0]
            if hou == "W":
                self.num[0], self.num[2], self.num[5], self.num[3] = self.num[2], self.num[5], self.num[3], self.num[0]
                tile = self.num[0]
            if hou == "N":
                self.num[0], self.num[1], self.num[5], self.num[4] = self.num[1], self.num[5], self.num[4], self.num[0]
                tile = self.num[0]
            if hou == "E":
                self.num[0], self.num[3], self.num[5], self.num[2] = self.num[3], self.num[5], self.num[2], self.num[0]
                tile = self.num[0]
        return tile


s = list(map(int, input().split()))
t = list(input())
idice = Dice(s, t)
print(idice.rotate())

Solution (Python):
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
d=input().split()
for x in input():
    d=[d[y]for y in r[x]]
print(d[0])

Solution (Python):
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 

class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
 
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def get_Top(self):
        return self.number[0]
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)
 
print("%d"%(dice.get_Top()))

Solution (Python):
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
d=input().split()
for x in input():
    d=[d[y]for y in r[x]]
print(d[0])

Solution (Python):
D = [
    (1, 5, 2, 3, 0, 4), 
    (3, 1, 0, 5, 4, 2), 
    (4, 0, 2, 3, 5, 1), 
    (2, 1, 5, 0, 4, 3), 
]
C = 'NESW'

*L, = map(int, input().split())
for c in input():
    L[:] = (L[e] for e in D[C.index(c)])
print(L[0])

Solution (Python):
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 

class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
 
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def get_Top(self):
        return self.number[0]
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)
 
print("%d"%(dice.get_Top()))

Solution (Python):
n = list(map(int,input().split()))

order = input()
a1,a2,a3,a4,b1,b2 = 1,5,6,2,3,4



for i in order:
  if i == 'N':
    a_1 = a4
    a_2 = a1
    a_3 = a2
    a_4 = a3
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    
  elif i == 'S':
    a_1 = a2
    a_2 = a3
    a_3 = a4
    a_4 = a1
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    
  elif i == 'E':
    a_1 = b2
    a_2 = a2
    b_1 = a1
    a_3 = b1
    b_2 = a3
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    
  else:
    a_1 = b1
    b_1 = a3
    a_3 = b2
    b_2 = a1
    a_2 = a2
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    
    
print(n[int(a1)-1])

Solution (Python):
class Dice:
    
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

    def top(self):
        return self.faces[0]

n = list(map(int, input().split()))
dice = Dice(n[0], n[1], n[2], n[3], n[4], n[5])
cmd = input()
for op in cmd:
    dice.move(op)
print(dice.top())

Solution (Python):
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c
 
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
st=input()
for c in st:
    dice.rot(c)
print(dice.u)

Solution (Python):

start = [1,2,3,5,4,6]

def N():
    start[0],start[1],start[3],start[5] = \
    start[1],start[5],start[0],start[3]
    
def S():
    start[0],start[1],start[3],start[5] = \
    start[3],start[0],start[5],start[1]
    
def W():
    start[0],start[2],start[4],start[5] = \
    start[2],start[5],start[0],start[4]

def E():
    start[0],start[2],start[4],start[5] = \
    start[4],start[0],start[5],start[2]

if __name__ == "__main__":
    lst = list(map(int,input().split()))
    s = input()
    for i in range(len(s)):
        if s[i]=='S':
            S()
        if s[i]=='E':
            E()
        if s[i]=='W':
            W()
        if s[i]=='N':
            N()
    print(lst[start[0]-1])

Solution (Python):
d = list(map(int, input().split()))
rq = list(input())
for i in rq:
  if i == "E":
    d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
  elif i == "N":
    d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
  elif i == "S":
    d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
  elif i == "W":
    d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]
print(d[0])

Solution (Python):
daise=list(map(int,input().split()))
a=input()
A=list(a)
n=len(A)
for m in range(n):
	if A[m]=='S':
		x=daise[0]
		daise[0]=daise[4]
		daise[4]=daise[5]
		daise[5]=daise[1]
		daise[1]=x
	elif A[m]=='E':
		x=daise[0]
		daise[0]=daise[3]
		daise[3]=daise[5]
		daise[5]=daise[2]
		daise[2]=x
	elif A[m]=='W':
		x=daise[0]
		daise[0]=daise[2]
		daise[2]=daise[5]
		daise[5]=daise[3]
		daise[3]=x
		pass
	elif A[m]=='N':
		x=daise[0]
		daise[0]=daise[1]
		daise[1]=daise[5]
		daise[5]=daise[4]
		daise[4]=x
		pass
print(daise[0])

Solution (Python):
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 input():
    dice = [dice[i] for i in mask[c]]

print(dice[0])

Solution (Python):
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))

Solution (Python):
s = list(map(int,input().split()))
ORDER = input()
order = list(ORDER)

for i in order:
  if i == 'E':
    s[0], s[3] = s[3], s[0]
    s[3], s[5] = s[5], s[3]
    s[5], s[2] = s[2], s[5]
    
  if i == 'N':
    s[0], s[1] = s[1], s[0]
    s[1], s[5] = s[5], s[1]
    s[5], s[4] = s[4], s[5]
    
    
  if i == 'S':
    s[0], s[4] = s[4], s[0]
    s[4], s[5] = s[5], s[4]
    s[5], s[1] = s[1], s[5] 
    
  if i == 'W':
    s[0], s[2] = s[2], s[0]
    s[2], s[5] = s[5], s[2]
    s[5], s[3] = s[3], s[5]

print(s[0])

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):

class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]



dice = Dice()
n = list(map(int, input().split()))
dice.setNumber(n[0], n[1], n[2], n[3], n[4], n[5])
directions = input()
for direction in directions:
    dice.roll(direction)
print(dice.get_Top())

Solution (Python):
def rot(s):
    if s=="E":
        return [4,2,1,6,5,3]
    elif s=="W":
        return [3,2,6,1,5,4]
    elif s=="S":
        return [5,1,3,4,6,2]
    elif s=="N":
        return [2,6,3,4,1,5]
    
label = tuple(map(int,input().split()))
surf = [0,1,2,3,4,5]
l = [0,0,0,0,0,0]
com = list(input())
for c in com:
    l = rot(c)
    surf[0],surf[1],surf[2],surf[3],surf[4],surf[5]=surf[l[0]-1],surf[l[1]-1],surf[l[2]-1],surf[l[3]-1],surf[l[4]-1],surf[l[5]-1]
print(label[surf[0]])

Solution (Python):
d = input().split()
s = {"N":"152304", "W":"215043", "E":"310542", "S":"402351"}
for o in input():
  d = [d[int(i)] for i in s[o]]
print(d[0])

Solution (Python):
l=map(int,raw_input().split())
n=raw_input()
ans=chk=0
 
 
def rolling(word,dice):
    if word=='S':
        dice[0],dice[1],dice[5],dice[4]=dice[4],dice[0],dice[1],dice[5]
    elif word=='N':
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    elif word=='W':
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    else:
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    return dice
 
for i in n:
    l=rolling(i,l)
print l[0]

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Solution (Python):
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}

d=input().split()   
for x in input(): 
    d=[d[y]for y in r[x]]   
    
print(d[0])

Solution (Python):
class Movedice:
    def __init__(self,list,position):
        self.list=list
        self.position=position
    def sortnumber(self):
        self.list[0],self.list[self.position]=self.list[self.position],self.list[0]
        self.list[5-self.position],self.list[5]=self.list[5],self.list[5-self.position]
        self.list[0],self.list[5]=self.list[5],self.list[0]
        return list

number=list(map(int,input().split()))
destination=list(input())
for i in range(len(destination)):
    if destination[i]=='N':
        movedice=Movedice(number,4)
        movedice.sortnumber()
    elif destination[i]=='E':
        movedice=Movedice(number,2)
        movedice.sortnumber()
    elif destination[i]=='W':
        movedice=Movedice(number,3)
        movedice.sortnumber()
    else:
        movedice=Movedice(number,1)
        movedice.sortnumber()
print(number[0])

Solution (Python):
def roll_positive(list_a: list, list_b: list) -> list:
    list_a = list_a[1:] + list_a[0:1]  
    list_b[0] = list_a[0]  
    list_b[2] = list_a[2]  
    return [list_a, list_b]


def roll_negative(list_a: list, list_b: list) -> list:
    list_a = list_a[3:] + list_a[0:3]
    list_b[0] = list_a[0]  
    list_b[2] = list_a[2]  
    return [list_a, list_b]


if __name__ == "__main__":
    faces_int = list(map(lambda x: int(x), input().split()))  
    SN_direction = [faces_int[5], faces_int[4], faces_int[0], faces_int[1]]  
    WE_direction = [faces_int[5], faces_int[2], faces_int[0], faces_int[3]]  
    commands = input()

    for command in commands:
        if ("N" == command):
            SN_direction, WE_direction = roll_positive(SN_direction, WE_direction)
        elif ("S" == command):
            SN_direction, WE_direction = roll_negative(SN_direction, WE_direction)
        elif ("E" == command):
            WE_direction, SN_direction = roll_positive(WE_direction, SN_direction)
        else:
            WE_direction, SN_direction = roll_negative(WE_direction, SN_direction)

    print(f"{SN_direction[2]}")

Solution (Python):
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0],
                           self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2],
                           self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2],
                           self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5],
                           self.work[0], self.work[4], self.work[3])

    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d" % (dice.get_Top()))

Solution (Python):
n = list(map(int,input().split()))
order = list(input())

for i in range(len(order)):
    if order[i] == 'E':
        temp = n[0]
        n[0] = n[3]
        n[3] = n[5]
        n[5] = n[2]
        n[2] = temp
    elif order[i] == 'W':
        temp = n[0]
        n[0] = n[2]
        n[2] = n[5]
        n[5] = n[3]
        n[3] = temp
    elif order[i] == 'S':
        temp = n[0]
        n[0] = n[4]
        n[4] = n[5]
        n[5] = n[1]
        n[1] = temp
    else:
        temp = n[0]
        n[0] = n[1]
        n[1] = n[5]
        n[5] = n[4]
        n[4] = temp

print(n[0])

Solution (Python):
class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

    def E(self):
        self.top, self.bottom, self.left, self.right = self.left, self.right, self.bottom, self.top

    def W(self):
        self.left, self.right, self.bottom, self.top = self.top, self.bottom, self.left, self.right


dice=Dice(*[int(i) for i in input().split(" ")])
for s in input():
    if s=="S":
        dice.S()
    if s=="E":
        dice.E()
    if s=="N":
        dice.N()
    if s=="W":
        dice.W()
print(dice.top)

Solution (Python):
def rotateDice(direction: str, dice: dict) -> dict:
    if direction == 'S':
        dice['S'], dice['F'], dice['N'], dice['B'] = dice['F'], dice['N'], dice['B'], dice['S']
    elif direction == 'E':
        dice['E'], dice['F'], dice['W'], dice['B'] = dice['F'], dice['W'], dice['B'], dice['E']
    elif direction == 'W':
        dice['W'], dice['F'], dice['E'], dice['B'] = dice['F'], dice['E'], dice['B'], dice['W']
    elif direction == 'N':
        dice['N'], dice['F'], dice['S'], dice['B'] = dice['F'], dice['S'], dice['B'], dice['N']
    return dice
 
 
dice_list = list(map(int, input().split()))
dice = {'FSEWNB'[i]: dice_list[i] for i in range(6)}
for c in input():
    dice = rotateDice(c, dice)
print(dice['F'])

Solution (Python):
dice = list(map(int, input().split()))
order = input()
for i in range(len(order)):
  c = order[i]
  if c == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif c == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif c == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif c == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
print(dice[0])

Solution (Python):
d1,d2,d3,d4,d5,d6 =map(int,input().split())

a=input()

task=len(a)


for i in range(task):
	if a[i]=='E':
		d1,d2,d3,d4,d5,d6=d4,d2,d1,d6,d5,d3
	if a[i]=='N':
		d1,d2,d3,d4,d5,d6=d2,d6,d3,d4,d1,d5
	if a[i]=='S':
		d1,d2,d3,d4,d5,d6=d5,d1,d3,d4,d6,d2
	if a[i]=='W':
		d1,d2,d3,d4,d5,d6=d3,d2,d6,d1,d5,d4
print(d1)

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()