output_description: Print the first three characters of the label of the N-th round of AtCoder
  Beginner Contest.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: n, c = [int(i) for i in input().split()]
  d = []
  for i in range(c):
      d.append(list(map(int, input().split())))
  color = []
  for i in range(n):
      color.append(list(map(int, input().split())))
  for i in range(n):
      for j in range(n):
          color[i][j] -= 1
  dofc = [[0 for i in range(3)] for j in range(c)]
  for t in range(3):
      for a in range(c):
          for l in range(n):
              for row in range(n):
                  dofc[a][(l + row) % 3] += d[a][color[row][l]]
  D = dofc[0][0] + dofc[1][1] + dofc[2][2]
  for c0 in range(c):
      for c1 in range(c):
          if c1 == c0:
              continue
          for c2 in range(c):
              if c2 == c1 or c2 == c0:
                  continue
              D = min(D, dofc[c0][0] + dofc[c1][1] + dofc[c2][2])
  print(D)
  
problem_description: Statement
  
  Decades have passed since the beginning of AtCoder Beginner Contest.
  
  The contests are labeled as `ABC001`, `ABC002`, ... from the first round, but
  after the 999-th round `ABC999`, a problem occurred: how the future rounds
  should be labeled?
  
  In the end, the labels for the rounds from the 1000-th to the 1998-th are
  decided: `ABD001`, `ABD002`, ..., `ABD999`.
  
  You are given an integer N between 1 and 1998 (inclusive). Print the first
  three characters of the label of the N-th round of AtCoder Beginner Contest.
samples: [{"input": "999", "output": "ABC\n    \n\nThe 999-th round of AtCoder Beginner Contest is labeled as `ABC999`.\n\n* * *"}, {"input": "1000", "output": "ABD\n    \n\nThe 1000-th round of AtCoder Beginner Contest is labeled as `ABD001`.\n\n* * *"}, {"input": "1481", "output": "ABD\n    \n\nThe 1481-th round of AtCoder Beginner Contest is labeled as `ABD482`."}]