require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
h,w,m = gets.chomp.split.map(&:to_i)
set = Set.new
rows = Array.new(h, 0)
cols = Array.new(w, 0)
m.times do
  y,x = gets.chomp.split.map{|e| e.to_i - 1}
  rows[y] += 1
  cols[x] += 1
  set.add [y, x]
end

rowmax = rows.max
colmax = cols.max

rows = rows.zip((0...h).to_a)
cols = cols.zip((0...w).to_a)

rows0 = rows.select{|row| row[0] == rowmax}
cols0 = cols.select{|col| col[0] == colmax}

rows0.each do |row_v, row_i|
  cols0.each do |col_v, col_i|
    unless set.include? [row_i, col_i]
      puts row_v + col_v
      exit
    end
  end
end
puts rows0[0][0] + cols0[0][0] - 1
