## https://yukicoder.me/problems/no/2229 MOD = 998244353 def main(): H, W, K = map(int, input().split()) xyv = [] for _ in range(K): x, y, v = map(int, input().split()) xyv.append((x, y, v)) answer = 0 for x, y, v in xyv: ans = x ans0 = ((x - 1) * x) % MOD ans0 *= pow(2, MOD -2, MOD) ans0 %= MOD d = max(0, x - y) ans1 = (d * (d + 1)) % MOD ans1 *= pow(2, MOD - 2, MOD) ans1 %= MOD ans += (ans0 - ans1) % MOD ans %= MOD d = max(0, x - (W + 1 - y)) ans2 = (d * (d + 1)) % MOD ans2 *= pow(2, MOD - 2, MOD) ans2 %= MOD ans += (ans0 - ans2) % MOD ans %= MOD answer += (v * ans) % MOD answer %= MOD print(answer) if __name__ == "__main__": main()