H,W,K=map(int, input().split()) mod=998244353 A=[[0]*W for _ in range(H)] for i in range(K): x,y,v=map(int, input().split()) x-=1 y-=1 A[x][y]=v ans=0 for h in range(H): for w in range(W): for hh in range(H): for ww in range(W): if hh+ww>=h+w and hh-ww>=h-w: ans+=A[hh][ww] ans%=mod print(ans)