Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

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



Sample input:
1 2 4 8 16 32
SE


Sample output:
8

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, data):
        self.data = data

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

    def getTop(self):
        return self.data[0]

dice = Dice.Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def _init_ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3].self.data[5],self.data[2],self.data[0]

            """tmp = self.data[0]
            self.data[0] = self.data[3]
            self.data[3] = self.data[5]
            self.data[5] = self.data[2]
            self.data[2] = tmp"""
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4].self.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4].self.data[0],self.data[1],self.data[5]
        elif firection == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2].self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice.Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def _init_ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3].self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4].self.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4].self.data[0],self.data[1],self.data[5]
        elif firection == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2].self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice.Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def _init_ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3].self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4].self.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4].self.data[0],self.data[1],self.data[5]
        elif firection == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2].self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice.dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def _init_ (self,data):
        self.data = data

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

    def getTop(self):
        return self.data[0]

dice = Dice.Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def _init_ (self,data):
        self.data = data

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

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
    def _init_ (self,data):
        self.data = data

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

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
    def _init_ (self,data):
        self.data = data

class Dice:
    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3].self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4].self.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4].self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2].self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
    def __init__ (self,data):
        self.data = data

class Dice:
    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3],self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4],elf.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4],self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2],self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3],self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[1],elf.data[0],self.data[4],self.data[5]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4],self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2],self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

from Dice
dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:

    def __init__ (self,data):
        self.data = data

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

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

Submission status: Runtime Error

Solution code:
# 1: top, 2: front, 3: right,
# 4: left, 5: back, 6: bottom

class Dice:
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, direction):
        if direction == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if direction == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if direction == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if direction == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

    def get_top(self):
        return self.top

if __name__ == '__main__':
    nums = [int(i) for i in input().split()]
    directions = input()

    d = Dice(nums)
    for i in len(directions):
        d.roll(directions[i])

    print(d.get_top())

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys
import io
import re
import math
import itertools
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
#start = time.clock()
ans=chk=0
a=[0,2,5,3]
b=[0,1,5,4]

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

def sortdice(dice1,dice2,p,q):
    for i in range(4):
        dice1[p[0]],dice1[p[1]],dice1[p[2]],dice1[p[3]]=dice1[p[1]],dice1[p[2]],dice1[p[3]],dice1[p[0]]
        for j in range(4):
            dice1[q[0]],dice1[q[1]],dice1[q[2]],dice1[q[3]]=dice1[q[1]],dice1[q[2]],dice1[q[3]],dice1[q[0]]
            if dice1==dice2:
                print 'Yes'
                exit()
    return 0

l1=map(int,raw_input().split())
l2=map(int,raw_input().split())
sortdice(l1,l2,a,b)
print 'No'

Submission status: Runtime Error

Solution code:
import random
class Dice:
    def __init__(self, ls):
        self.top,   self.bottom = ls[0], ls[5]
        self.right, self.left   = ls[2], ls[3]
        self.front, self.back   = ls[1], ls[4]

    def rot(self, d):
        if   d == "N":
            (self.top, self.back, self.bottom, self.front) = (
             self.front, self.top, self.back, self.bottom)
        elif d == "S":
            (self.top, self.back, self.bottom, self.front) = (
             self.back, self.bottom, self.front, self.top)
        elif d == "E":
            (self.top, self.right, self.bottom, self.left) = (
             self.left, self.top, self.right, self.bottom)
        elif d == "W":
            (self.top, self.right, self.bottom, self.left) = (
             self.right, self.bottom, self.left, self.top)

    def show(self):
        return (self.top, self.bottom, self.right,
                self.left, self.front, self.back)

S = set()
N = int(raw_input())
judge = True
for i in xrange(N):
    dice = Dice(map(int, raw_input().split()))
    s = set()
    for loop in xrange(1000):
        nums = dice.show()
        if nums in S:
            judge = False
            break
        s.add(nums)
        dice.rot("NSEW"[random.randint(0, 3)])
    if not judge:
        break
    S |= s
print "Yes" if judge else "No"

Submission status: Runtime Error

Solution code:
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]


dice = Dice(list(map(int, input().split)))
commands = input()

for c in commands:
    if c == "N":
        dice.roll_north()
    elif c == "S":
        dice.roll_south()
    elif c == "W":
        dice.roll_west()
    elif c == "E":
        dice.roll_east()
print(dice.number(1))

Submission status: Runtime Error

Solution code:
axis_1 = '0154' * 2  # 2 -> 3
axis_2 = '0253' * 2  # 4 -> 1
axis_3 = '3124' * 2  # 0 -> 5

right = [axis_3, axis_2[::-1], axis_1, axis_1[::-1], axis_2, axis_3[::-1], ]
a = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    top, front = map(a.index, map(int, input().split()))
    x = '%d%d' % (top, front)
    for i, axis in enumerate(right):
        if x in axis:
            print(a[i])
            break
    else:
        print('------------------')
        print(x)

Submission status: Runtime Error

Solution code:
class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

  def print_all(self):
    print "top = " + self.top
    print "front = " + self.front
    print "right = " + self.right
    print "left = " + self.left
    print "back = " + self.back
    print "bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

my_dice = dice.Dice(raw_input().split(" "))
order = raw_input()
for i in xrange(len(order)):
  if order[i] == "E":
    my_dice.roll_E()
  elif order[i] == "N":
    my_dice.roll_N()
  elif order[i] == "S":
    my_dice.roll_S()
  elif order[i] == "W":
    my_dice.roll_W()
  else:
    continue

print my_dice.top

Submission status: Runtime Error

Solution code:
class Dice:
??
????????def __init__(self, faces):
????????????????self.faces = tuple(faces)
??
????????def roll_north(self):
????????????????self.faces = (self.faces[1], self.faces[5], self.faces[2],
????????????????????????????????????????????self.faces[3], self.faces[0], self.faces[4])
??
????????def roll_south(self):
????????????????self.faces = (self.faces[4], self.faces[0], self.faces[2],
????????????????????????????????????????????self.faces[3], self.faces[5], self.faces[1])
??
????????def roll_west(self):
????????????????self.faces = (self.faces[2], self.faces[1], self.faces[5],
????????????????????????????????????????????self.faces[0], self.faces[4], self.faces[3])
??
????????def roll_east(self):
????????????????self.faces = (self.faces[3], self.faces[1], self.faces[0],
????????????????????????????????????????????self.faces[5], self.faces[4], self.faces[2])
??
????????def number(self, face_id):
????????????????return self.faces[face_id - 1]
??
??
dice = Dice(list(map(int, input().split())))
commands = input()
??
for c in commands:
????????if c == "N":
????????????????dice.roll_north()
????????elif c == "S":
????????????????dice.roll_south()
????????elif c == "W":
????????????????dice.roll_west()
????????elif c == "E":
????????????????dice.roll_east()
print(dice.number(1))

Submission status: Runtime Error

Solution code:
class Dice(object):
	def __init__(self,List):
		self.face=List
	
	def n_spin(List):
		temp=List[0]
		List[0]=List[1]
		List[1]=List[5]
		List[5]=List[4]
		List[4]=temp

	def s_spin(List):
		temp=List[0]
		List[0]=List[4]
		List[4]=List[5]
		List[5]=List[1]
		List[1]=temp

	def e_spin(lList):
		temp=List[0]
		List[0]=List[3]
		List[3]=List[5]
		List[5]=List[2]
		List[2]=temp

	def w_spin(lList):
		temp=List[0]
		List[0]=List[2]
		List[2]=List[5]
		List[5]=List[3]
		List[3]=temp

dice = Dice(map(int,raw_input().split())
command = list(raw_input())
for k in command:
	if k=='N':
		dice.n_spin(dice.face)
	elif k=='S':
		dice.s_spin(dice.face)
	elif k=='E':
		dice.e_spin(dice.face)
	else:
		dice.w_spin(dice.face)
print dice.face[0]

Submission status: Runtime Error

Solution code:
class dice:
    def __init__(self,label):
        self.d = label
    def roll(self,op):
        d = self.d
        if   op=='N': self.d = [d[1],d[5],d[2],d[3],d[0],d[4]]
        elif op=='E': self.d = [d[3],d[1],d[0],d[5],d[4],d[2]]
        elif op=='W': self.d = [d[2],d[1],d[5],d[0],d[4],d[3]]
        elif op=='S': self.d = [d[4],d[0],d[2],d[3],d[5],d[1]]
    def print(self):
        print(self.d[0])
    def print_r_side(self,t,f):
        d = self.d
        if   (t,f)==(d[0],d[1]): print(d[2])
        elif (t,f)==(d[0],d[2]): print(d[4])
        elif (t,f)==(d[0],d[3]): print(d[1])
        elif (t,f)==(d[0],d[4]): print(d[3])
        elif (t,f)==(d[1],d[0]): print(d[3])
        elif (t,f)==(d[1],d[2]): print(d[0])
        elif (t,f)==(d[1],d[3]): print(d[5])
        elif (t,f)==(d[1],d[5]): print(d[2])
        elif (t,f)==(d[2],d[0]): print(d[1])
        elif (t,f)==(d[2],d[1]): print(d[5])
        elif (t,f)==(d[2],d[4]): print(d[0])
        elif (t,f)==(d[2],d[5]): print(d[4])
        elif (t,f)==(d[3],d[0]): print(d[4])
        elif (t,f)==(d[3],d[1]): print(d[0])
        elif (t,f)==(d[3],d[4]): print(d[5])
        elif (t,f)==(d[3],d[5]): print(d[1])
        elif (t,f)==(d[4],d[0]): print(d[2])
        elif (t,f)==(d[4],d[2]): print(d[5])
        elif (t,f)==(d[4],d[3]): print(d[0])
        elif (t,f)==(d[4],d[5]): print(d[3])
        elif (t,f)==(d[5],d[1]): print(d[3])
        elif (t,f)==(d[5],d[2]): print(d[1])
        elif (t,f)==(d[5],d[3]): print(d[4])
        elif (t,f)==(d[5],d[4]): print(d[2])

label = list(map(int,input().split()))
q = int(input())
d0 = dice(label)
for _ in range(q):
    t,f = list(map(int,input().split()))
    d0.print_r_side(t,f)

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, labels):
        self.labels = labels
        self.up = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.down = labels[5]
    def east(self):
        self.up, self.right, self.down, self.left = self.left, self.up, self.right, self.down
        self.update_labels()
    def north(self):
        self.up, self.back, self.down, self.front = self.front, self.up, self.back, self.down
        self.update_labels()
    def south(self):
        self.up, self.front, self.down, self.back = self.back, self.up, self.front, self.down
        self.update_labels()
    def west(self):
        self.up, self.left, self.down, self.right = self.right, self.up, self.left, self.down
        self.update_labels()
    def clockwise(self):
        self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        self.update_labels()
    def counterclockwise(self):
        self.front, self.right, self.back, self.left = self.left, self.front, self.right, self.back
        self.update_labels()
    def set_up(self, up):
        for i in range(6):
            if up == self.up:
                break
            if i % 2:
                self.east()
            else:
                self.north()
    def set_front(self, front):
        while True:
            if front == self.front:
                break
            self.clockwise()
    def update_labels(self):
        self.labels = [self.up, self.front, self.right, self.left, self.back, self.down]

dice_1 = Dice(list(map(int, input().split())))
dice_2 = Dice(list(map(int, input().split())))
flag = False
for i in range(30):
    if dice_1.labels == dice_2.labels:
        flag = True
        break
    if i % 5 == 0:
        if i % 10 == 0:
            dice_2.east()
        else:
            dice_2.north()
    else:
        dice_2.clockwise()
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self):
		# ???????????????????????°
		# ????????¶???
		self.x = [2, 5]
		self.y = [3, 4]
		self.z = [1, 6]
		SN = {'S': 0, 'N': 1}
		WE = {'W': 0, 'E': 1}
		pass

	def rotate(self, _dir):
		def rot(_k, _r):
			return list(reversed(_r)), _k

		if _dir=='N':
			self.x, self.z = rot(self.x, self.z)
		elif _dir=='S':
			self.z, self.x = rot(self.z, self.x)
		elif _dir=='E':
			self.z, self.y = rot(self.z, self.y)
		elif _dir=='W':
			self.y, self.z = rot(self.y, self.z)
		else:
			pass

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

	def view(self):
		print("x, y, z =", self.x, self.y, self.z)

if __name__=="__main__":
	val = list(map(int, input().split()))
	dice = Dice()
	dr = input()
	for d in dr:
		dice.rotate(d)
	print(val(dice.top()))

Submission status: Runtime Error

Solution code:
class Dice:
 
    def __init__(self, faces):
        self.faces = tuple(faces)
 
    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])
 
    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])
 
    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])
 
    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])
    
    def roll_roll(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]

    def is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(4):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_roll()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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