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:
      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)
  
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"}]