#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll modc = 998244353; ll f(ll x, ll n){ return ((x * (n+1)) % modc - (n * (n+1) / 2) % modc + modc) % modc; } int main(){ ll H, W, K, x, y, v, ans=0; cin >> H >> W >> K; for (int i=0; i> x >> y >> v; ans += ((f(x, min(y-1, x)) + f(x, min(W-y, x)) + modc - x) % modc) * v % modc; ans %= modc; } cout << ans << endl; return 0; }