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: import collections
  
  h, w, m = (int(each) for each in input().split())
  
  bombs = []
  for each in range(m):
      bombs.append(tuple(int(each) for each in input().split()))
  
  hbombs = [each[0] for each in bombs]
  wbombs = [each[1] for each in bombs]
  
  # h方向で行番号と対象の数のタプル
  hbombs_cnt = collections.Counter(hbombs).most_common()
  wbombs_cnt = collections.Counter(wbombs).most_common()
  
  hbombs_max = hbombs_cnt[0][1]
  wbombs_max = wbombs_cnt[0][1]
  
  # h方向で一番多い行番号と対象の数のタプル
  hbombs_most_common = [each for each in hbombs_cnt if each[1] == hbombs_max]
  wbombs_most_common = [each for each in wbombs_cnt if each[1] == wbombs_max]
  
  # print(hbombs_most_common)
  # print(wbombs_most_common)
  
  result = hbombs_max + wbombs_max
  
  pos = [0]
  
  # 爆破位置に爆弾があるか
  for _h in hbombs_most_common:
      for _w in wbombs_most_common:
          # print(_h[0], _w[0])
          if (_h[0], _w[0]) in bombs:
              pos.append(1)
  # print(pos)
  print(result - max(pos))
  
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"}]