Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !

Dice = [1,2,3] # top,front,right

def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
    
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
    
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d

def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d

def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d

def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d



while True:
    n = int(input())
    if n == 0:
        break
    
    dice = [1,2,3]
    result = 1
    
    for _ in range(n):
        direction = input()
        # if direction == 'North':
        #     dice = North(dice)
        # if direction == 'East':
        #     dice = East(dice)
        # if direction == 'South':
        #     dice = South(dice)
        # if direction == 'West':
        #     dice = West(dice)
        dice = eval(direction+"(dice)")
        #print(dice)
        
        result += dice[0]
    
    print(result)
        

Fixed submission:
# coding: utf-8
# Here your code !
import sys
f = sys.stdin

def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
      
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
      
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d
  
def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d
  
def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d
  
def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d
  
  
  
while True:
    n = int(f.readline())
    if n == 0:
        break
      
    dice = [1,2,3]
    result = 1
      
    for _ in range(n):
        direction = f.readline().rstrip()
   
        dice = eval(direction+"(dice)")
     
          
        result += dice[0]
      
    print(result)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !

Dice = [1,2,3] # top,front,right

def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
    
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
    
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d

def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d

def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d

def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d



while True:
    n = int(input())
    if n == 0:
        break
    
    dice = [1,2,3]
    result = 1
    
    for _ in range(n):
        direction = input()
        dice = eval(direction+"(dice)")
        #print(dice)
        
        result += dice[0]
    
    print(result)
        

Fixed submission:
# coding: utf-8
# Here your code !
import sys
f = sys.stdin

def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
      
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
      
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d
  
def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d
  
def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d
  
def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d
  
  
  
while True:
    n = int(f.readline())
    if n == 0:
        break
      
    dice = [1,2,3]
    result = 1
      
    for _ in range(n):
        direction = f.readline().rstrip()
   
        dice = eval(direction+"(dice)")
     
          
        result += dice[0]
      
    print(result)

Buggy python submission (verdict: Runtime Error):
import sys
 
operator = sys.stdin.read().split()
     
top = 1
bottom = 6
south = 2
north = 5
east = 3
west = 4
sum = 1
 
for var in operator[1:]:
    if var == "North":
        north,top,south,bottom = top,south,bottom,north
        sum += top
    elif var == "South":
        south,top,north,bottom = top,north,bottom,south
        sum += top
    elif var == "West":
        west,top,east,bottom = top,east,bottom,west
        sum += top
    elif var == "East":
        east,top,west,bottom = top,west,bottom,east
        sum += top
    elif var == "Right":
        south,east,north,west = east,north,west,south
        sum += top
    elif var == "Left":
        south,west,north,east = west,north,east,south
        sum += top
    else:
        print sum
        top = 1
        bottom = 6
        south = 2
        north = 5
        east = 3
        west = 4
        sum = 1

Fixed submission:
# coding: utf-8
# Here your code !
import sys
f = sys.stdin

def North(d):
    d = [d[1]] + [7 -d[0]] + [d[2]]
    return d
      
def East(d):
    d = [7-d[2]] + [d[1]] + [d[0]]
    return d
      
def South(d):
    d = [7-d[1]] + [d[0]] + [d[2]]
    return d
  
def West(d):
    d = [d[2]] + [d[1]] + [7-d[0]]
    return d
  
def Right(d):
    d = [d[0]] + [d[2]] + [7-d[1]]
    return d
  
def Left(d):
    d = [d[0]] + [7-d[2]] + [d[1]]
    return d
  
  
  
while True:
    n = int(f.readline())
    if n == 0:
        break
      
    dice = [1,2,3]
    result = 1
      
    for _ in range(n):
        direction = f.readline().rstrip()
   
        dice = eval(direction+"(dice)")
     
          
        result += dice[0]
      
    print(result)