Problem:


サイコロが以下の図のような向きで置かれている．

ここで使用するサイコロは，この図のように，上側に 1，南側に 2 があるときは，東側に 3 があるものとする．サイコロの向かいあう面の和は必ず 7 なので，見えない面はそれぞれ北側 5，西側 4，下側 6 になっている．

　この初期配置の状態から指示に従ってサイコロを動かしていく．ただし，指示は以下の 6 通りの操作を何回か行うものである． 

North，East，South，West の各操作は指示された方向へサイコロを 90 度回転させる．
　Right，Left の 2 つの操作は上下の面はそのままで水平方向に 90 度回転させる．（回転させる向きに要注意．）

　初期配置で上の面に出ている目 1 を初期値とし， 1 回の操作が終わるたびに，上の面に出ている目の数を加算していき，指示にしたがってすべての操作を終えたときの合計値を出力するプログラムを作成しなさい.

　入力ファイルの 1 行目には総指示回数 n が書かれていて，続く n 行の各行には「North，East，South，West，Right，Left」のいずれか 1 つの指示が書かれているものとする．ただし， n ≦ 10000 とする． 

 

  入力例１入力例２

 

58

NorthWest

NorthNorth

EastLeft

SouthSouth

WestRight

North

Left

East

  　

  出力例１  出力例２

2134

入力

入力は複数のデータセットからなる．n が 0 のとき入力が終了する．データセットの数は 5 を超えない．

出力

データセットごとに、合計値を１行に出力する．

入力例

5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0

出力例

21
34

各データセットの出力（合計値）の後に改行を入れること。

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0


Sample output:
21
34

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

while True:
    n = raw_input()
    if n == 0: break

    a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
    s = 0
    for i in range(n):
        op = raw_input()
        if op == "North":
            a, b, f, d = b, f, d, a
        elif op == "East":
            a, c, f, e = e, a, c, f
        elif op == "West":
            a, e, f, c = c, a, e, f
        elif op == "South":
            a, b, f, d = d, a, b, f
        elif op == "Right":
            b, c, d, e = c, d, e, b
        elif op == "Left":
            b, c, d, e = e, b, c, d
        s += a
    print s

Submission status: Runtime Error

Solution code:
while True:
    n = raw_input()
    if n == 0: break

    a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
    s = 0
    for i in range(n):
        op = raw_input()
        if op == "North":
            a, b, f, d = b, f, d, a
        elif op == "East":
            a, c, f, e = e, a, c, f
        elif op == "West":
            a, e, f, c = c, a, e, f
        elif op == "South":
            a, b, f, d = d, a, b, f
        elif op == "Right":
            b, c, d, e = c, d, e, b
        elif op == "Left":
            b, c, d, e = e, b, c, d
        s += a
    print s

Submission status: Runtime Error

Solution code:
while True:
    n = str(raw_input())
    if n == 0: break

    a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
    s = 0
    for i in range(n):
        op = raw_input()
        if op == "North":
            a, b, f, d = b, f, d, a
        elif op == "East":
            a, c, f, e = e, a, c, f
        elif op == "West":
            a, e, f, c = c, a, e, f
        elif op == "South":
            a, b, f, d = d, a, b, f
        elif op == "Right":
            b, c, d, e = c, d, e, b
        elif op == "Left":
            b, c, d, e = e, b, c, d
        s += a
    print s

Submission status: Runtime Error

Solution code:
while 1:
    T,U,N,E,W,S=1,6,5,3,4,2
    n=int(raw_input())
    if n==0: break
    ans=T
    for i in range(n):
        di=raw_input()
        if di=="North":
            N,T,S,U=T,S,U,N
        elif di=="East":
            E,U,W,T=T,E,U,W
        elif di=="South":
            T,S,U,N=N,T,S,U
        elif di=="West":
            T,E,U,W=E,U,W,T
        elif di=="Left":
            E,S,W,N=S,W,N,E
        elif di=="Right":
            S,W,N,E=E,S,W,N
        else:
            print '[*] Error ->',di
            raise IOError
        ans+=T
    print ans

Submission status: Runtime Error

Solution code:
while 1:
    T,U,N,E,W,S=1,6,5,3,4,2
    n=int(raw_input())
    if n==0: break
    ans=T
    for i in range(n):
        di=raw_input()
        if di=="North":
            N,T,S,U=T,S,U,N
        elif di=="East":
            E,U,W,T=T,E,U,W
        elif di=="South":
            T,S,U,N=N,T,S,U
        elif di=="West":
            T,E,U,W=E,U,W,T
        elif di=="Left":
            E,S,W,N=S,W,N,E
        elif di=="Right":
            S,W,N,E=E,S,W,N
        else:
            print '[*] Error ->',di
            raise IOError
        ans+=T
????????????print ans

Submission status: Runtime Error

Solution code:
# 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)

Submission status: Runtime Error

Solution code:
# 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)

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  new_cube = []
  for i in xrange(count):
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
    new_cube = []

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  new_cube = []
  sum = 0
  for i in xrange(count):
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
    new_cube = []
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 0
  for i in xrange(count):
    new_cube = []
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in operation[raw_input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    new_cube.append(previous_cube[operation[raw_input()][0]])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    new_cube.append(previous_cube[operation[raw_input()][0]])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][e]])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = input()
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left'[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for i in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][i]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(6):
      new_cube.append(previous_cube[operation[raw_input()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(6):
      new_cube.append(previous_cube[operation[str(raw_input())][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[str(raw_input())][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count-1):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[str(raw_input())][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[str(raw_input().strip)][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[str(raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while True:
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while True:
  count = input()
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6),
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        new_dice = [dice[s - 1] for s in orders[input()]]
        dice = new_dice
        top += dice[0]
        n -= 1
    print(top)

Submission status: Runtime Error

Solution code:
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        new_dice = [dice[s - 1] for s in orders[input()]]
        dice = new_dice
        top += dice[0]
        n -= 1
    print(top)

Submission status: Runtime Error

Solution code:
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)

Submission status: Runtime Error

Solution code:
print('dummy')

orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)

Submission status: Runtime Error

Solution code:
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)
exit()

Submission status: Runtime Error

Solution code:
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        exit()
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)

Submission status: Runtime Error

Solution code:
while True:
  count = input()
  if count == 0: break
  previous_cube = [0, 1, 2, 3, 4, 5]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while True:
  count = input()
  if count == 0: break
  previous_cube = [ 1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().split()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while True:
  count = input()
  if count == 0: break
  previous_cube = [ 1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
while True:
  count = input()
  if count == 0: break
  previous_cube = [ 1, 2, 3, 4, 5, 6]
  operation = {'North':[1, 5, 2, 3, 0, 4], 'East':[3, 1, 0, 5, 4, 2], 'West': [2, 1, 5, 0, 4, 3], 'South':[4, 0, 2, 3, 5, 1], 'Right':[0, 2, 4, 1, 3, 5], 'Left':[0, 3, 1, 4, 2, 5]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[str(raw_input())][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

Submission status: Runtime Error

Solution code:
UP=0
SOURTH=1
EAST=2

saikoro = [1,2,3]

def north():
    before=[saikoro[0], saikoro[1],saikoro[2]]
    saikoro[UP] = before[SOURTH]
    saikoro[SOURTH] = 7-before[UP]
    

def south():
    before=[saikoro[0], saikoro[1],saikoro[2]]
    saikoro[UP] = 7- before[SOURTH]
    saikoro[SOURTH] = before[UP]

def east():
   before=[saikoro[0], saikoro[1],saikoro[2]]
   saikoro[UP]=7-before[EAST]
   saikoro[EAST]=before[UP]

def west():
   before=[saikoro[0], saikoro[1],saikoro[2]]
   saikoro[UP]=before[EAST]
   saikoro[EAST]=7-before[UP]

def right():
   before=[saikoro[0], saikoro[1],saikoro[2]]
   saikoro[SOURTH]=before[EAST]
   saikoro[EAST]=7-before[SOURTH]


def left():
   before=[saikoro[0], saikoro[1],saikoro[2]]
   saikoro[SOURTH]=7-before[EAST]
   saikoro[EAST]=before[SOURTH]


funcs = {"North": north,
         "South": south,
         "East": east,
         "West": west,
         "Right": right,
         "Left": left,}

while True:
    n = input()
    if n == 0:
        break
    
    saikoro = [1,2,3]
    sum=1
    
    for x in xrange(n):
        cmd = raw_input()
        funcs[cmd]()
        sum+=saikoro[UP]
    
    print sum

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

dice = [1,2,3]#top,face,right
sum = 1

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

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]#top,face,right
    sum = 1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]#top,face,right
    sum = 1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]#top,face,right
    sum = 1
    sums = []

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        sums.append(sum)
        dice =  [1,2,3]
        sum = 1
    [print(e)for e in sums]
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]#top,face,right
    sum = 1
    sums = []

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        sums.append(sum)
        dice =  [1,2,3]
        sum = 1
    [print(e)for e in sums]
    return 0
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]#top,face,right
    sum = 1

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        print(sum)
        dice =  [1,2,3]
        sum = 1
    return 0
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def North(dice):
    dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]
    sum = 1

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        print(sum)
        dice =  [1,2,3]
        sum = 1
    return 0
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def North(dice):
??????dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]
    sum = 1

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        print(sum)
        dice =  [1,2,3]
        sum = 1
    return 0
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# coding: UTF-8

def North(dice):
??????dice[0],dice[1] = dice[1],7-dice[0]

def East(dice):
    dice[2],dice[0] = dice[0],7-dice[2]

def West(dice):
    dice[0],dice[2] = dice[2],7-dice[0]

def South(dice):
    dice[1],dice[0] = dice[0],7-dice[1]

def Right(dice):
    dice[1],dice[2] = dice[2],7-dice[1]

def Left(dice):
    dice[2],dice[1] = dice[1],7-dice[2]

def main():
    dice = [1,2,3]
    sum = 1

    while 1:
        n = int(input())
        if not n:
            break
        for _ in range(n):
            eval(input()+"(dice)")
            sum += dice[0]
        print(sum)
        dice =  [1,2,3]
        sum = 1
    return 0
if __name__ == "__main__":
    main()