h,w,q=map(int,input().split()) yx=[list(map(int,input().split())) for _ in range(q)] now=h*w d={} for y,x in yx: if x in d: if d[x]