def rectangle(len): return 0 if len < 0 else ((len)*(len+1)//2) def inverted(W, I, J, V): cnt = (I+1)*(I+1)-rectangle(I-J)-rectangle(I+J+1-W) return V * cnt % 998244353 def main(): H, W, K = map(int, input().split()) assert(1 <= H and H <= 100000) assert(1 <= W and W <= 100000) assert(0 <= K and K <= min(H*W, 200000)) XYVs = [None for _ in range(K)] for i in range(K): X, Y, V = map(int, input().split()) assert(1 <= X and X <= H) assert(1 <= Y and Y <= W) assert(0 <= V and V <= 1000000000) X -= 1 Y -= 1 XYVs[i] = (X, Y, V) ans = 0 for x, y, v in XYVs: ans += inverted(W, x, y, v) print(ans) if __name__ == '__main__': main()