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