H,W,K=map(int,input().split()) XYV=[list(map(int,input().split())) for _ in range(K)] Map = [[0]*W for _ in range(H)] for x,y,v in XYV: Map[x-1][y-1]=v MOD=998244353 ans=0 for i in range(H): for j in range(W): for x in range(H): for y in range(W): if i+j<=x+y and i-j<=x-y: ans+=Map[x][y] ans%=MOD print(ans)