output_description: For each question, print the integer on the right side face.
input_description: In the first line, six integers assigned to faces are given in ascending order
  of their corresponding labels. In the second line, the number of questions $q$
  is given.
  
  In the following $q$ lines, $q$ questions are given. Each question consists of
  two integers on the top face and the front face respectively.
attempt: n = list(map(int, input().split()))
  q = int(input())
  l = [[3, 5, 2, 4], [4, 1, 6, 3], [2, 6, 1, 5], [5, 1, 6, 2], [3, 6, 1, 4], [4, 2, 5, 3]]
  for i in range(q):
      a, b = map(int, input().split())
      for j in range(6):
          if a == n[j]:
              c = j
          if b == n[j]:
              d = j
      e = d
      if c < d:
          e -= 1
      if c + d > 5:
          e -= 1
      print(n[l[c][e] - 1])
  
problem_description: Dice II
  
    
  
  Construct a dice from a given sequence of integers in the same way as Dice I.
  
  You are given integers on the top face and the front face after the dice was
  rolled in the same way as Dice I. Write a program to print an integer on the
  right side face.
  
    
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ITP1_11_B)
samples: [{"input": "2 3 4 5 6\n    3\n    6 5\n    1 3\n    3 2", "output": "5\n    6"}]