R, C = map(int, input().split()); P = {} for _ in range(int(input())): a, r, c = map(int, input().split()) for _ in range(a): P[1<