require 'pp'

###################

#inputType = :singleLine
# inputType = :2Lines
inputType = :nLines
  
def main(query)
  h,w,m = query.shift

  th = {}
  tw = {}
  t = {}
  query.each { | l |
    bh,bw = tois(l.split(" "))
    th[bh] = (th[bh] || 0) + 1
    tw[bw] = (tw[bw] || 0) + 1
    tk = bh.to_s + "," + bw.to_s
    t[tk] = (t[tk] || 0) + 1 
  }

  sum = 0

  ppp "th=",th
  ppp "tw=",tw
  ppp "t=",t
  
  th.keys.each { | h |
    tw.keys.each { | w |
      tt = t[h.to_s + "," + w.to_s] || 0      
      
      s = th[h] + tw[w] - tt
      if (sum < s) then
        sum = s
      end
    }
  }
  
  return [sum]
end

###################

TEST=false

def tois(l)
  l.map { | x | x.to_i}
end

def ppp(msg, val)
  if (TEST) then
    print msg
    pp val
  end
end

target = nil
if (ARGV.size == 0) then
  f = STDIN
end
if (ARGV.size > 0) then
  f = open(ARGV[0])
end
if (ARGV.size > 1) then
  target = ARGV[1].to_i
end

t = 1
ng = []
while true
  query = []
  if (inputType == :singleLine) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
  elsif (inputType == :l2Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
  elsif (inputType == :l3Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
    c = f.gets.chomp
    query.push c
  elsif (inputType == :nLines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a    

    n = a.split(" ")[2].to_i

    n.times { | i |
      query.push f.gets.chomp
    }    
  end
  
  aa = f.gets
  if ! aa then
    r = main(query) 
    r.each { | x | puts x }
    exit
  elsif ( aa.chomp == "---") then
    oks = []
    while true
      s = f.gets.chomp
      if (s == "===") then
        break
      end
      oks.push s
    end

    if (target == nil || t == target) then
      if target then
        TEST = true
      end

      puts "--- " + t.to_s + " ---"
      r = main(query)    

      if r.join('\n') == oks.join('\n') then
        puts "RESULT:"
        r.each { | x | puts x }
        puts "OK"
      else
        puts "RESULT:NG"
        r.each { | x | puts x }
        puts "NG!!!!!!!!!"
        ng.push t
      end
    end
  end
  t = t + 1
end
puts "---"
puts "NG targes = " + ng.to_s
