#include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) const ll mod = 998244353; int main(){ int h,w,k; cin >> h >> w >> k; vector> val(h,vector(w)); rep(i,k){ int a,b; ll x; cin >> a >> b >> x; val[a-1][b-1] = x; } ll ans = 0; for (int i = 0; i < h;i++){ for (int j = 0; j < w;j++){ for (int x = 0; x < h;x++){ for (int y = 0; y < w;y++){ if (x+y >= i+j && x-y >= i-j){ ans += val[x][y]; ans%=mod; } } } } } cout << ans << endl; return 0; }