output_description: Print the integer which appears on the top face after the simulation.
input_description: 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.
attempt: class Dice(object):
  
      def __init__(self, d):
  
          self.rows = [d[0], d[4], d[5], d[1]]
          self.cols = [d[0], d[2], d[5], d[3]]
  
      def move_next_rows(self):
          temp = self.rows.pop(0)
          self.rows.append(temp)
          self.__update(self.cols, self.rows)
  
      def move_prev_rows(self):
          temp = self.rows.pop(3)
          self.rows.insert(0, temp)
          self.__update(self.cols, self.rows)
  
      def move_next_cols(self):
          temp = self.cols.pop(0)
          self.cols.append(temp)
          self.__update(self.rows, self.cols)
  
      def move_prev_cols(self):
          temp = self.cols.pop(3)
          self.cols.insert(0, temp)
          self.__update(self.rows, self.cols)
  
      def __update(self, x, y):
          x[0] = y[0]
          x[2] = y[2]
  
  
  class DiceChecker(object):
  
      def __init__(self, dice1, dice2):
          self.dice1 = dice1
          self.dice2 = dice2
          self.dice1_top = self.dice1.rows[0]
          self.dice1_front = self.dice1.rows[3]
  
      def check_same_dice(self):
  
          is_same = False
          for _ in range(4):
              for _ in range(4):
                  is_same_element = (
                      self.dice1.rows == self.dice2.rows
                      and self.dice1.cols == self.dice2.cols
                  )
                  if is_same_element:
                      is_same = True
                      break
                  self.dice2.move_next_cols()
              else:
                  self.dice2.move_next_rows()
                  continue
              break
          if is_same:
              print("Yes")
          else:
              print("No")
  
      def __find_num(self, x, dice):
          i = 0
          while x != dice.rows[0]:
              dice.move_next_rows()
              if i > 3:
                  dice.move_next_cols()
                  i = 0
              i += 1
  
      def __rot(self, dice):
          temp = dice.rows[1]
          dice.rows[1] = dice.rows[3]
          dice.rows[3] = temp
  
          temp = dice.cols[1]
          dice.cols[1] = dice.cols[3]
          dice.cols[3] = temp
  
  
  d1 = list(map(int, input().split(" ")))
  d2 = list(map(int, input().split(" ")))
  dice1 = Dice(d1)
  dice2 = Dice(d2)
  
  dice_checker = DiceChecker(dice1, dice2)
  dice_checker.check_same_dice()
  
problem_description: Dice I
  
    
  
  Write a program to simulate rolling a dice, which can be constructed by the
  following net.
  
    
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ITP1_11_A_1)  
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ITP1_11_A_2)  
    
    
  
  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.
samples: [{"input": "1 2 4 8 16 32\n    SE", "output": "8\n    \n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face\nlabeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction\nS and then to the direction E, you can see 8 on the top face."}, {"input": "1 2 4 8 16 32\n    EESWN", "output": "32"}]