#include using namespace std; using ll = long long; int main() { int h, w, K; cin >> h >> w >> K; vector> p(h, vector(w)); ll x, y, v; for(int i = 0; i < K; i++) { cin >> x >> y >> v; x--; y--; p[x][y] = v; } const ll mod = 998244353; ll ans = 0; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { for(int k = 0; k < h; k++) { for(int l = 0; l < w; l++) { if(k + l >= i + j && k - l >= i - j) { ans += p[k][l]; ans %= mod; } } } } } cout << ans << endl; return 0; }