#include // #include using namespace std; // using namespace atcoder; typedef long long ll; typedef vector vi; typedef vector vll; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);iint(b);--i) #define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define sort(x) sort(all(x)) #define rev(x) reverse(all(x)) const ll inf = (1LL<<60)+(1LL<<30); templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> H >> W >> K; vector field(H+1, vll(W+1)); ll x, y, v; rep(i, K) { cin >> x >> y >> v; field[x][y] = v; } auto op = [&](ll i, ll j) { ll res = 0; rep(x, 1, H+1) rep(y, 1, W+1) { if (x+y >= i+j && x-y >= i-j) res += field[x][y]; } return res; }; ll ans = 0; rep(i, 1, H+1) rep(j, 1, W+1) { ans += op(i, j); ans %= 998244353; } cout << ans << endl; }