output_description: Print the K-th element.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      K
attempt: def main():
      a = input()
      b = input()
      c = input()
      A, B, C = len(a), len(b), len(c)
      ab = [True] * 10000
      ac = [True] * 10000
      bc = [True] * 10000
  
      def check(c1, c2):
          if c1 == "?" or c2 == "?" or c1 == c2:
              return False
          return True
  
      for i in range(A):
          for j in range(B):
              if check(a[i], b[j]):
                  ab[i - j + 5000] = False
      for i in range(A):
          for j in range(C):
              if check(a[i], c[j]):
                  ac[i - j + 5000] = False
      for i in range(B):
          for j in range(C):
              if check(b[i], c[j]):
                  bc[i - j + 5000] = False
      ans = A + B + C
      for i in range(-(B + C), A + C):
          for j in range(-(B + C), A + B):
              if ab[i + 5000] and ac[j + 5000] and bc[j - i + 5000]:
                  L = min(0, i, j)
                  R = max(A, i + B, j + C)
                  ans = min(ans, R - L)
      print(ans)
  
  
  main()
  
problem_description: Statement
  
  Print the K-th element of the following sequence of length 32:
  
      
      
      1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
samples: [{"input": "6", "output": "2\n    \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n    \n\nThe 27-th element is 5."}]