output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W M
      h_1 w_1
      \vdots
      h_M w_M
attempt: # -*- coding: utf-8 -*-
  from collections import Counter, defaultdict
  
  
  import sys
  
  # sys.setrecursionlimit(10**6)
  # buff_readline = sys.stdin.buffer.readline
  buff_readline = sys.stdin.readline
  readline = sys.stdin.readline
  
  INF = 2**62 - 1
  
  
  def read_int():
      return int(buff_readline())
  
  
  def read_int_n():
      return list(map(int, buff_readline().split()))
  
  
  def read_float():
      return float(buff_readline())
  
  
  def read_float_n():
      return list(map(float, buff_readline().split()))
  
  
  def read_str():
      return readline().strip()
  
  
  def read_str_n():
      return readline().strip().split()
  
  
  def error_print(*args):
      print(*args, file=sys.stderr)
  
  
  def mt(f):
      import time
  
      def wrap(*args, **kwargs):
          s = time.time()
          ret = f(*args, **kwargs)
          e = time.time()
  
          error_print(e - s, "sec")
          return ret
  
      return wrap
  
  
  @mt
  def slv(H, W, M, HW):
      g = defaultdict(dict)
      for h, w in HW:
          g[h][w] = 1
      h = Counter(h for h, w in HW)
      w = Counter(w for h, w in HW)
      h = list(h.items())
      h.sort(reverse=True, key=lambda x: x[1])
      w = list(w.items())
      w.sort(reverse=True, key=lambda x: x[1])
  
      ans = 0
      for k, v in h:
          for kk, vv in w:
              if k in g and kk in g[k]:
                  ans = max(ans, v + vv - 1)
              else:
                  return ans
  
      return ans
  
  
  def main():
      H, W, M = read_int_n()
      HW = [read_int_n() for _ in range(M)]
      print(slv(H, W, M, HW))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  We have a two-dimensional grid with H \times W squares. There are M targets to
  destroy in this grid - the position of the i-th target is \left(h_i, w_i
  \right).
  
  Takahashi will choose one square in this grid, place a bomb there, and ignite
  it. The bomb will destroy all targets that are in the row or the column where
  the bomb is placed. It is possible to place the bomb at a square with a
  target.
  
  Takahashi is trying to maximize the number of targets to destroy. Find the
  maximum number of targets that can be destroyed.
samples: [{"input": "2 3 3\n    2 2\n    1 1\n    1 3", "output": "3\n    \n\nWe can destroy all the targets by placing the bomb at \\left(1, 2\\right).\n\n* * *"}, {"input": "3 3 4\n    3 3\n    3 1\n    1 1\n    1 2", "output": "3\n    \n\n* * *"}, {"input": "5 5 10\n    2 5\n    4 3\n    2 3\n    5 5\n    2 2\n    5 4\n    5 3\n    5 1\n    3 5\n    1 4", "output": "6"}]