#include using namespace std; using ll = long long; ll calc(ll H, ll W, ll r, ll c) { ll L, R; ll b = 0; if (r + c >= 2 && r >= c) { L = c - 1; b += max(0ll, r - c); } else { L = r - 1; } if (r + c >= 1 + W && r - c >= 1 - W) { R = W - c; b += max(0ll, r - 1 - (W - c)); } else { R = r - 1; } ll s = (L + R) * (r - 1) * 2 - L * L - R * R; b += (L + R + 1) * 2 - 2; ll a = (s - b + 1) / 2; return a + b; } ll const m = 998244353; int main () { ll H, W, K; cin >> H >> W >> K; ll ans = 0; for (int i = 0; i < K; i ++) { ll x, y, v; cin >> x >> y >> v; v %= m; ll c = calc(H, W, x, y) % m; ans += (c * v) % m; ans %= m; } cout << ans << endl; }