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: Wrong Answer

Solution code:
import sys

input=sys.stdin.read().split()
a=1
b=2
c=3
d=4
e=5
f=6
x=0

for command in input[1:]:



 if command=='North':
    a,b,d,f,c,e=b,f,a,d,c,e

 if command=='South':
    a,d,f,b,c,e=d,f,b,a,c,e

 if command=='West':
    a,e,c,f,d,b=c,a,f,e,d,b

 if command=='East':
    a,e,c,f,b,d=e,f,a,c,b,d

 if command=='Right':
    c,d,e,b,a,f=d,e,b,c,a,f

 if command=='Left':
    c,b,e,d,a,f=b,e,d,c,a,f
 print a
 print b
 print c
 print d
 print e
 print f
 print command
 x=x+a

print x

Submission status: Wrong Answer

Solution code:
import sys

input=sys.stdin.read().split()
a=1
b=2
c=3
d=4
e=5
f=6
x=0

for command in input[1:]:



 if command=='North':
    a,b,d,f,c,e=b,f,a,d,c,e

 if command=='South':
    a,d,f,b,c,e=d,f,b,a,c,e

 if command=='West':
    a,e,c,f,d,b=c,a,f,e,d,b

 if command=='East':
    a,e,c,f,b,d=e,f,a,c,b,d

 if command=='Right':
    c,d,e,b,a,f=d,e,b,c,a,f

 if command=='Left':
    c,b,e,d,a,f=b,e,d,c,a,f
 
 x=x+a

print x

Submission status: Wrong Answer

Solution code:
import sys

input=sys.stdin.read().split()
a=1
b=2
c=3
d=4
e=5
f=6
x=0

for command in input[1:]:



 if command=='North':
    a,b,d,f,c,e=b,f,a,d,c,e

 if command=='South':
    a,d,f,b,c,e=d,f,b,a,c,e

 if command=='West':
    a,e,c,f,d,b=c,a,f,e,d,b

 if command=='East':
    a,e,c,f,b,d=e,f,a,c,b,d

 if command=='Right':
    c,d,e,b,a,f=d,e,b,c,a,f

 if command=='Left':
    c,b,e,d,a,f=b,e,d,c,a,f
 
 
 x=x+a

print x

Submission status: Wrong Answer

Solution code:

cur = 1
adj = [2, 4, 5, 3]

dic = {'North' : 0, 'East' : 1, 'South' : -2, 'West' : -1}

n = int( raw_input() )

ans = 1

for i in range(n):
    cmd = raw_input()
    if cmd in ['North', 'East', 'South', 'West']:
        cur, adj[dic[cmd]], adj[dic[cmd]+2] = adj[dic[cmd]] , 7-cur, cur
    elif cmd == 'Left':
        adj = adj[1:] + adj[:1]
    elif cmd == 'Right':
        adj = adj[-1:] + adj[1:]
    ans += cur

print ans

Submission status: Wrong Answer

Solution code:


dic = {'North' : 0, 'East' : 1, 'South' : -2, 'West' : -1}

while True:
    n = int( raw_input() )
    if n == 0: break
    cur = 1
    adj = [2, 4, 5, 3]
    ans = 1
    for i in range(n):
        cmd = raw_input()
        if cmd in ['North', 'East', 'South', 'West']:
            cur, adj[ dic[cmd] ], adj[ dic[cmd] + 2 ] = adj[ dic[cmd] ] , 7-cur, cur
        elif cmd == 'Left':
            adj = adj[1:] + adj[:1]
        elif cmd == 'Right':
            adj = adj[-1:] + adj[1:]
        ans += cur
    print ans

Submission status: Wrong Answer

Solution code:
dic = {'North' : 0, 'East' : 1, 'South' : -2, 'West' : -1}

while True:
    n = int( raw_input() )
    if n == 0: break
    cur = 1
    adj = [2, 4, 5, 3]
    ans = 1
    for i in range(n):
        cmd = raw_input()
        if cmd in ['North', 'East', 'South', 'West']:
            cur, adj[ dic[cmd] ], adj[ dic[cmd] + 2 ] = adj[ dic[cmd] ] , 7-cur, cur
        elif cmd == 'Left':
            adj = adj[1:] + adj[:1]
        elif cmd == 'Right':
            adj = adj[-1:] + adj[:-1]
        ans += cur
        print cur, ',', adj
    print ans

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


x = ['Front', 'Right', 'Back', 'Left']
y = ['Front', 'Top', 'Back', 'Bottom']
z = ['Top', 'Right', 'Bottom', 'Left']


def turn(dice, direction):
    _dice = dice
    # x?????????
    if direction == 'Right':
        for i in range(4):
            _dice[x[i]] = dice[x[(i+1)%4]]

    if direction == 'Left':
        for i in range(4):
            _dice[x[i]] = dice[x[(i-1)%4]]

    # y?????????
    if direction == 'North':
        for i in range(4):
            _dice[y[i]] = dice[y[(i+1)%4]]
    if direction == 'South':
        for i in range(4):
            _dice[y[i]] = dice[y[(i-1)%4]]

    # z?????????
    if direction == 'East':
        for i in range(4):
            _dice[z[i]] = dice[z[(i+1)%4]]
    if direction == 'West':
        for i in range(4):
            _dice[z[i]] = dice[z[(i-1)%4]]

    return _dice

if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break

        dice = {'Top': 1, 'Front': 2, 'Right': 3,
                'Left': 4, 'Back': 5, 'Bottom': 6}
        ret = 0

        for i in range(n):
            dice = turn(dice, input())
            ret += dice['Top']

        print(ret)

Submission status: Wrong Answer

Solution code:
while True:
    n = int(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: Wrong Answer

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

    a, b, c, d, e, f = 1, 2, 3, 5, 4, 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: Wrong Answer

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

    a, b, c, d, e, f = 1, 2, 3, 5, 4, 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 + 1

Submission status: Wrong Answer

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

    a, b, c, d, e, f = 1, 2, 3, 5, 4, 6
    s = 1
    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: Wrong Answer

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

    a, b, c, d, e, f = 1, 2, 3, 5, 4, 6
    s = 1
    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: Wrong Answer

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

    a, b, c, d, e, f = 1, 2, 3, 5, 4, 6
    s = a
    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: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0 : break
	
	top = 1
	bottom = 6
	south = 2
	north = 5
	east = 3
	west = 4
	
	sum = 1
	for _ in xrange(n):
		operator = raw_input()
		if operator == "North":
			north,top,south,bottom = top,south,bottom,north
			sum += top
		if operator == "South":
			south,top,north,bottom = top,north,bottom,south
			sum += top
		if operator == "West":
			west,top,east,bottom = top,east,bottom,west
			sum += top
		if operator == "East":
			east,top,west,bottom = top,west,bottom,east
			sum += top
		if operator == "Right":
			south,east,north,west = east,north,west,south
			sum += top
		if operator == "Left":
			south,west,north,east = west,north,east,south
			sum += top
			
	print sum

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0 : break
	
	top = 1
	bottom = 6
	south = 2
	north = 5
	east = 3
	west = 4
	
	sum = 1
	for _ in xrange(n):
		operator = raw_input()
		if operator == "North":
			north,top,south,bottom = top,south,bottom,north
			sum += top
		elif operator == "South":
			south,top,north,bottom = top,north,bottom,south
			sum += top
		elif operator == "West":
			west,top,east,bottom = top,east,bottom,west
			sum += top
		elif operator == "East":
			east,top,west,bottom = top,west,bottom,east
			sum += top
		elif operator == "Right":
			south,east,north,west = east,north,west,south
			sum += top
		elif operator == "Left":
			south,west,north,east = west,north,east,south
			sum += top
			
	print sum

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0 : break
	
	top = 1
	bottom = 6
	south = 2
	north = 5
	east = 3
	west = 4
	
	sum = 1
	for _ in xrange(n):
		operator = str(raw_input())
		
		if operator == "North":
			north,top,south,bottom = top,south,bottom,north
			sum += top
		elif operator == "South":
			south,top,north,bottom = top,north,bottom,south
			sum += top
		elif operator == "West":
			west,top,east,bottom = top,east,bottom,west
			sum += top
		elif operator == "East":
			east,top,west,bottom = top,west,bottom,east
			sum += top
		elif operator == "Right":
			south,east,north,west = east,north,west,south
			sum += top
		elif operator == "Left":
			south,west,north,east = west,north,east,south
			sum += top
			
	print sum

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0 : break
	
	top = 1
	bottom = 6
	south = 2
	north = 5
	east = 3
	west = 4
	
	operator = [raw_input() for _ in xrange(n)]
	sum = 1
	for var in operator:
		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
			
	print sum

Submission status: Wrong Answer

Solution code:
while True:
	n = raw_input()
	if n == "0" : break
	
	top = 1
	bottom = 6
	south = 2
	north = 5
	east = 3
	west = 4
	
	operator = [raw_input() for _ in range(0, int(n))]
	sum = 1
	for var in operator:
		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
			
	print sum

Submission status: Wrong Answer

Solution code:
import sys

operator = sys.stdin.readlines()
operator = [operator[i].replace("\n", "") for i in xrange(len(operator))]
	
top = 1
bottom = 6
south = 2
north = 5
east = 3
west = 4
sum = 1

for var in operator:
	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:
		if sum != 1:
			print sum
		top = 1
		bottom = 6
		south = 2
		north = 5
		east = 3
		west = 4
		sum = 1

Submission status: Wrong Answer

Solution code:
import sys

operator = sys.stdin.readlines()
operator = [operator[i].replace("\n", "") for i in xrange(len(operator))]
	
top = 1
bottom = 6
south = 2
north = 5
east = 3
west = 4
sum = 1

for var in operator:
	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

Submission status: Wrong Answer

Solution code:
import sys

operator = sys.stdin.readlines()
operator = [operator[i].replace("\n", "") for i in xrange(len(operator))]
	
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

Submission status: Wrong Answer

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)
        if direction == 'Right':
            dice = Right(dice)
        if direction == 'Left':
            dice = Left(dice)
        #dice = eval(direction+"(dice)")
        #print(dice)
        
        result += dice[0]
    
    print(result)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

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)
        if direction == 'Right':
            dice = Right(dice)
        if direction == 'Left':
            dice = Left(dice)
        #dice = eval(direction+"(dice)")
        #print(dice)
        
        result += dice[0]
    
    print(result)

Submission status: Wrong Answer

Solution code:

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)
        if direction == 'Right':
            dice = Right(dice)
        if direction == 'Left':
            dice = Left(dice)
        #dice = eval(direction+"(dice)")
        #print(dice)
        
        result += dice[0]
    
    print(result)

Submission status: Wrong Answer

Solution code:
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)
        if direction == 'Right':
            dice = Right(dice)
        if direction == 'Left':
            dice = Left(dice)
        #dice = eval(direction+"(dice)")
        #print(dice)
         
        result += dice[0]
     
    print(result)

Submission status: Wrong Answer

Solution code:
print('dummy')
exit()

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: Wrong Answer

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()]]
        print('dummy')
        exit()
        top += dice[0]
        n -= 1
    print(top)

Submission status: Wrong Answer

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('dummy')
    exit()
    print(top)

Submission status: Wrong Answer

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
    exit()
    print(top)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
while 1:
	n=input()
	if n==0:break
	cnt=1
	d=[1,2,6,5,4,3]
	for i in xrange(n):
		com=raw_input()
		print d
		if com=="North":
			d[0],d[1],d[2],d[3]=d[1],d[2],d[3],d[0]
		elif com=="West":
			d[0],d[5],d[2],d[4]=d[5],d[2],d[4],d[0]
		elif com=="East":
			d[0],d[4],d[2],d[5]=d[4],d[2],d[5],d[0]
		elif com=="South":
			d[0],d[1],d[2],d[3]=d[3],d[0],d[1],d[2]
		elif com=="Left":
			d[1],d[5],d[3],d[4]=d[4],d[1],d[5],d[3]
		else:
			d[1],d[5],d[3],d[4]=d[5],d[3],d[4],d[1]
		cnt+=d[0]
	print(cnt)

Submission status: Wrong Answer

Solution code:
while 1:
	n=input()
	if n==0:break
	cnt=1
	d=[1,2,6,5,4,3]
	for i in xrange(n):
		com=raw_input()
		if com=="North":
			d[0],d[1],d[2],d[3]=d[1],d[2],d[3],d[0]
		elif com=="West":
			d[0],d[5],d[2],d[4]=d[5],d[2],d[4],d[0]
		elif com=="East":
			d[0],d[4],d[2],d[5]=d[4],d[2],d[5],d[0]
		elif com=="South":
			d[0],d[1],d[2],d[3]=d[3],d[0],d[1],d[2]
		elif com=="Left":
			d[1],d[5],d[3],d[4]=d[4],d[1],d[5],d[3]
		else:
			d[1],d[5],d[3],d[4]=d[5],d[3],d[4],d[1]
		cnt+=d[0]
	print(cnt)

Submission status: Wrong Answer

Solution code:
n=input()
cnt=1
d=[1,2,6,5,4,3]
for i in xrange(n):
	com=raw_input()
	if com=="North":
		d[0],d[1],d[2],d[3]=d[1],d[2],d[3],d[0]
	elif com=="West":
		d[0],d[5],d[2],d[4]=d[5],d[2],d[4],d[0]
	elif com=="East":
		d[0],d[4],d[2],d[5]=d[4],d[2],d[5],d[0]
	elif com=="South":
		d[0],d[1],d[2],d[3]=d[3],d[0],d[1],d[2]
	elif com=="Left":
		d[1],d[5],d[3],d[4]=d[4],d[1],d[5],d[3]
	else:
		d[1],d[5],d[3],d[4]=d[5],d[3],d[4],d[1]
	cnt+=d[0]
print(cnt)

Submission status: Wrong Answer

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,}

n = input()
sum=1
for x in xrange(n):
    cmd = raw_input()
    funcs[cmd]()
    sum+=saikoro[UP]

print sum

Submission status: Wrong Answer

Solution code:
while True:
    n = input()
    if n == 0:
        break
    a, b, c = 1, 2, 3
    sum=1
    for x in xrange(n):
        cmd = raw_input()
        if "North" == cmd:
            a, b = b, 7-a
        elif "South" == cmd:
            a, b = 7- b, a
        elif "East"== cmd:
            a, c =7-c, a
        elif "West"== cmd:
            a,c=c,7-a
        elif "Right"== cmd:
            b, c = c, 7-b
        elif "Left"== cmd:
            b, c = 7-c, b
        sum+=a
    print sum

Submission status: Wrong Answer

Solution code:
class Dice:
 
    def __init__(self):
        self._top = 1
        self._front = 2
        self._side = 3
        self._sum = 1
 
    def to_north(self):
        tmp = self._top
        self._top = self._front
        self._front = 7 - tmp 
        self._sum += self._top
 
    def to_east(self):
        tmp = self._top
        self._top = 7 - self._side
        self._side = tmp
        self._sum += self._top
 
    def to_west(self):
        tmp = self._top
        self._top = self._side
        self._side = 7 - tmp
        self._sum += self._top
 
    def to_south(self):
        tmp = self._top
        self._top = 7 - self._front
        self._front = tmp
        self._sum += self._top
 
    def to_right(self):
        tmp = self._front
        self._front = self._side
        self._side = 7 - tmp
        self._sum += self._top
 
    def to_left(self):
        tmp = self._front
        self._front = 7 - self._side
        self._side = tmp
        self._sum += self._top
 
    def get_sum(self):
        return self._sum
 
if __name__ == '__main__':
    d = ['North', 'East', 'South', 'West', 'Right', 'Left']
 
    while True:
        dice = Dice()
        n = input()
        if n == 0:
            break
 
        for i in xrange(n):
            t = raw_input()
            if t == d[0]:
                dice.to_north() 
            elif t == d[1]:
                dice.to_east()
            elif t == d[2]:
                dice.to_south()
            elif t == d[3]:
                dice.to_west()
            elif t == d[4]:
                dice.to_right()
            elif t == d[5]:
                dice.to_left()
 
        print(dice.get_sum())

Submission status: Wrong Answer

Solution code:
class Dice:

    def __init__(self):
        self._top = 1
        self._front = 2
        self._side = 3
        self._sum = 1

    def to_north(self):
        tmp = self._top
        self._top = self._front
        self._front = 7 - tmp
        self._sum += self._top

    def to_east(self):
        tmp = self._top
        self._top = 7 - self._side
        self._side = tmp
        self._sum += self._top

    def to_west(self):
        tmp = self._top
        self._top = self._side
        self._side = 7 - tmp
        self._sum += self._top

    def to_south(self):
        tmp = self._top
        self._top = 7 - self._front
        self._front = tmp
        self._sum += self._top

    def to_right(self):
        tmp = self._front
        self._front = self._side
        self._side = 7 - tmp
        self._sum += self._top

    def to_left(self):
        tmp = self._front
        self._front = 7 - self._side
        self._side = tmp
        self._sum += self._top

    def get_sum(self):
        return self._sum

if __name__ == '__main__':
    d = ['North', 'East', 'South', 'West', 'Right', 'Left']

    while True:
        dice = Dice()
        n = input()
        if n == 0:
            break

        for i in xrange(n):
            t = raw_input()
            if t == d[0]:
                dice.to_north()
            elif t == d[1]:
                dice.to_east()
            elif t == d[2]:
                dice.to_south()
            elif t == d[3]:
                dice.to_west()
            elif t == d[4]:
                dice.to_right()
            elif t == d[5]:
                dice.to_left()

        print(dice.get_sum())

Submission status: Wrong Answer

Solution code:

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
def dice_swap(a, b):
    return b, (7-a)
 
def f(s, a, b, c):
    if s == 'North':
        a, b = dice_swap(a, b)
    elif s == 'East':
        c, a = dice_swap(c, a)
    elif s == 'West':
        a, c = dice_swap(a, c)
    elif s == 'South':
        b, a = dice_swap(b, a)
    elif s == 'Right':
        b, c = dice_swap(b, c)
    elif s == 'Left':
        c, b = dice_swap(c, b)
    return a, b, c
 
while True:
    n = int(raw_input())
    if n == 0:
        break
    r, a, b, c = 1, 1, 2, 3
    for _ in range(n):
        a, b, c = f(raw_input(), a, b, c)
        r += a
    print r

Submission status: Wrong Answer

Solution code:
def dice_swap(a, b):
    return b, (7-a)
 
def f(s, a, b, c):
    if s == 'North':
        a, b = dice_swap(a, b)
    elif s == 'East':
        c, a = dice_swap(c, a)
    elif s == 'West':
        a, c = dice_swap(a, c)
    elif s == 'South':
        b, a = dice_swap(b, a)
    elif s == 'Right':
        b, c = dice_swap(b, c)
    elif s == 'Left':
        c, b = dice_swap(c, b)
    return a, b, c
 
while True:
    n = int(raw_input())
    if n == 0:
        break
    r, a, b, c = 1, 1, 2, 3
    for _ in range(n):
        a, b, c = f(raw_input(), a, b, c)
        r += a
    print r

Submission status: Wrong Answer

Solution code:
def dice_swap(a, b):
    return b, (7-a)

def f(s, a, b, c):
    if s == 'North':
        a, b = dice_swap(a, b)
    elif s == 'East':
        c, a = dice_swap(c, a)
    elif s == 'West':
        a, c = dice_swap(a, c)
    elif s == 'South':
        b, a = dice_swap(b, a)
    elif s == 'Right':
        b, c = dice_swap(b, c)
    elif s == 'Left':
        c, b = dice_swap(c, b)
    return a, b, c

while True:
    n = int(raw_input())
    if n == 0:
        break
    r, a, b, c = 1, 1, 2, 3
    for _ in range(n):
        a, b, c = f(raw_input(), a, b, c)
        r += a
    print r