H,W,K=map(int,input().split()) v=[[0]*W for _ in range(H)] x,y=[],[] for _ in range(K): x,y,hv=map(int,input().split()) x-=1 y-=1 v[x][y]=hv mod=998244353 les=0 for i in range(H): for j in range(W): for x in range(H): for y in range(W): if x+y>=i+j and x-y>=i-j: les+=v[x][y]%mod print(les%mod)