output_description: Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print
  `8`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      X
attempt: n = int(input())
  A = [list(input().split()) for i in range(n)]
  l = 2 * 10**5 + 5
  # l = 500
  # B = [[int(A[i][0]), int(A[i][1]), int(A[i][0])+int(A[i][1]), int(A[i][0])-int(A[i][1])+l, A[i][2]] for i in range(n)]
  
  D = [[[] for j in range(2 * l)] for i in range(4)]
  
  # for i in range(4):
  #     for j in range(n):
  #         D[i][B[j][i]].append(B[j])
  
  for i in range(n):
      x = int(A[i][0])
      y = int(A[i][1])
      nn = [x, y, A[i][2]]
      D[0][x].append(nn)
      D[1][y].append(nn)
      D[2][x + y].append(nn)
      D[3][x - y + l].append(nn)
  
  # print(D)
  import bisect
  
  ans = float("inf")
  for i in range(l):
      # print(D[1][i])
      LR = [[], []]
      for j in range(len(D[1][i])):
  
          if D[1][i][j][2] == "L":
              LR[0].append(D[1][i][j][0])
          if D[1][i][j][2] == "R":
              LR[1].append(D[1][i][j][0])
  
          # print(j,LR)
          for k in range(len(LR[1])):
              ind = bisect.bisect(LR[0], LR[1][k])
              if ind != len(LR[0]):
                  ans = min(ans, (LR[0][ind] - LR[1][k]) * 5)
  
  for i in range(l):
      # print(D[0][i])
      LR = [[], []]
      for j in range(len(D[0][i])):
  
          if D[0][i][j][2] == "U":
              LR[0].append(D[0][i][j][1])
          if D[0][i][j][2] == "D":
              LR[1].append(D[0][i][j][1])
  
          # print(j,LR)
          for k in range(len(LR[0])):
              ind = bisect.bisect(LR[1], LR[0][k])
              # print("ind",ind)
              if ind != len(LR[1]):
                  ans = min(ans, (LR[1][ind] - LR[0][k]) * 5)
  
  for i in range(2 * l):
      # print(D[1][i])
      LR = [[], []]
      LR2 = [[], []]
      for j in range(len(D[2][i])):
  
          if D[2][i][j][2] == "L":
              LR[0].append(D[2][i][j][0])
          if D[2][i][j][2] == "D":
              LR[1].append(D[2][i][j][0])
  
          if D[2][i][j][2] == "U":
              LR2[0].append(D[2][i][j][0])
          if D[2][i][j][2] == "R":
              LR2[1].append(D[2][i][j][0])
  
          # print(j,LR)
          for k in range(len(LR[1])):
              ind = bisect.bisect(LR[0], LR[1][k])
              if ind != len(LR[0]):
                  ans = min(ans, (LR[0][ind] - LR[1][k]) * 10)
  
          for k in range(len(LR2[1])):
              ind = bisect.bisect(LR2[0], LR2[1][k])
              if ind != len(LR2[0]):
                  ans = min(ans, (LR2[0][ind] - LR2[1][k]) * 10)
  
  for i in range(2 * l):
      # print(D[1][i])
      LR = [[], []]
      LR2 = [[], []]
      for j in range(len(D[3][i])):
  
          if D[3][i][j][2] == "D":
              LR[0].append(D[3][i][j][1])
          if D[3][i][j][2] == "R":
              LR[1].append(D[3][i][j][1])
  
          if D[3][i][j][2] == "L":
              LR2[0].append(D[3][i][j][1])
          if D[3][i][j][2] == "U":
              LR2[1].append(D[3][i][j][1])
  
          # print(j,LR)
          for k in range(len(LR[1])):
              ind = bisect.bisect(LR[0], LR[1][k])
              if ind != len(LR[0]):
                  ans = min(ans, (LR[0][ind] - LR[1][k]) * 10)
  
          for k in range(len(LR2[1])):
              ind = bisect.bisect(LR2[0], LR2[1][k])
              if ind != len(LR2[0]):
                  ans = min(ans, (LR2[0][ind] - LR2[1][k]) * 10)
  
  
  if ans == float("inf"):
      ans = "SAFE"
  print(ans)
  
problem_description: Statement
  
  M-kun is a competitor in AtCoder, whose highest rating is X.  
  In this site, a competitor is given a _kyu_ (class) according to his/her
  highest rating. For ratings from 400 through 1999, the following kyus are
  given:
  
    * From 400 through 599: 8-kyu
    * From 600 through 799: 7-kyu
    * From 800 through 999: 6-kyu
    * From 1000 through 1199: 5-kyu
    * From 1200 through 1399: 4-kyu
    * From 1400 through 1599: 3-kyu
    * From 1600 through 1799: 2-kyu
    * From 1800 through 1999: 1-kyu
  
  What kyu does M-kun have?
samples: [{"input": "725", "output": "7\n    \n\nM-kun's highest rating is 725, which corresponds to 7-kyu.  \nThus, `7` is the correct output.\n\n* * *"}, {"input": "1600", "output": "2\n    \n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.  \nThus, `2` is the correct output."}]