Buggy python submission (verdict: Runtime Error):
class Dice(object):
    def __init__(self):
        self.upside = 1
	self.frontside = 2
	self.rightside = 3
	self.backside = 4
	self.leftside = 5
	self.downside = 6
		
    def throwDice(self,dir):
	up = self.upside
	front = self.frontside
	left = self.leftside
	if dir == "S":
	    self.frontside = up
	    self.backside = 7-up
	    self.downside = front
            self.upside = 7-front
			
	elif dir == "N":
	    self.frontside = 7-up
	    self.backside = up
	    self.downside = 7-front
	    self.upside = front
			
	elif dir == "E":
	    self.rightside = up
	    self.leftside = 7-up
	    self.upside = left
	    self.downside = 7-left
		
	elif dir == "W":
	    self.rightside = 7-up
	    self.leftside = up
	    self.upside = 7-left
	    self.downside = left
	
	def getUpside(self):
	    return self.upside
		
n = list(map(int,input().split()))
com = list(input())

dice = Dice()
for i in range(len(com)):
	dice.throwDice(com[i])

print(n[dice.getUpside()-1])

	
	
	

Fixed submission:
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
up,front,right,left,back,bottom = input().split()
direction = list(input())

for i in range(len(direction)):
    up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,direction[i])
    
print(up)

Buggy python submission (verdict: Runtime Error):
class Dice(object):
    def __init__(self):
        self.upside = 1
	self.frontside = 2
	self.rightside = 3
	self.backside = 4
	self.leftside = 5
	self.downside = 6
		
    def throwDice(self,dir):
	up = self.upside
	front = self.frontside
	left = self.leftside
	if dir == "S":
	    self.frontside = up
	    self.backside = 7-up
	    self.downside = front
            self.upside = 7-front
			
	elif dir == "N":
	    self.frontside = 7-up
	    self.backside = up
	    self.downside = 7-front
	    self.upside = front
			
	elif dir == "E":
	    self.rightside = up
	    self.leftside = 7-up
	    self.upside = left
	    self.downside = 7-left
		
	elif dir == "W":
	    self.rightside = 7-up
	    self.leftside = up
	    self.upside = 7-left
	    self.downside = left
	
    def getUpside(self):
	    return self.upside
		
n = list(map(int,input().split()))
com = list(input())

dice = Dice()
for i in range(len(com)):
	dice.throwDice(com[i])

print(n[dice.getUpside()-1])

	
	
	

Fixed submission:
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
up,front,right,left,back,bottom = input().split()
direction = list(input())

for i in range(len(direction)):
    up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,direction[i])
    
print(up)

Buggy python submission (verdict: Runtime Error):
def whatIsRight(u,f):	
    r = 0
    if u == 1:
        if f == 2:
            r = 3
        elif f == 3:
            r = 5
        elif f == 4:
            r = 2
        elif f == 5:
            r = 4
        return r
	
    if u == 2:
        if f == 6:
            r = 3
        elif f == 3:
            r = 1
        elif f == 1:
            r = 4
        elif f == 4:
            r = 6
        return r

    if u == 3:
        if f == 5:
            r = 1
        elif f == 1:
            r = 2
        elif f == 2:
            r = 6
        elif f == 6:
            r = 3
        return r
			
    if u == 4:
        if f == 6:
            r = 2
        elif f == 2:
            r = 1
        elif f == 1:
            r = 5
        elif f == 5:
            r = 6 
        return r 
			
    if u == 5:
        if f == 3:
            r = 6
        elif f == 6:
            r = 4
        elif f == 4:
            r = 1
        elif f == 1:
            r = 3
	return r
		
    if u == 6:
        if f == 5:
            r = 3
        elif f == 3:
            r = 2
        elif f == 2:
            r = 4
        elif f == 4:
            r = 5
        return r
			
n = list(map(int,input().split()))
N = int(input())

for i in range(N):
    m = list(map(int,input().split()))
    num = []

    for j in range(len(m)):
        for k in range(len(n)):
            if m[j] == n[k]:
                num.append(k+1)
                break
	
    print(n[whatIsRight(num[0],num[1]) -1])

Fixed submission:
def move(up,bottom,right,left,front,back,direction):
    if direction == "N":
        return (front,back,right,left,bottom,up)
    elif direction == "S":
        return (back,front,right,left,up,bottom)
    elif direction == "E":
        return (left,right,up,bottom,front,back)
    elif direction == "W":
        return (right,left,bottom,up,front,back)
    
up,front,right,left,back,bottom = input().split()
direction = list(input())

for i in range(len(direction)):
    up,bottom,right,left,front,back = move(up,bottom,right,left,front,back,direction[i])
    
print(up)