#include using namespace std; #if __has_include() #include using namespace atcoder; typedef modint998244353 mint; #endif typedef long long ll; typedef pair pii; typedef pair pll; const int INF = 1e9; const long long LINF = 1e18; const int MOD = 998244353; const int MOD1 = 1e9+7; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(x) x.begin(), x.end() template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} void yorn(bool ans){cout << (ans?"Yes":"No") << endl; return;} // しばらくはsize_tをキャストに任せてみようかな int main(){ int h,w,k; cin >> h >> w >> k; vector x(k),y(k),v(k); rep(i,k) cin >> x.at(i) >> y.at(i) >> v.at(i); vector> g(h,vector(w)); rep(i,k){ g.at(x.at(i)-1).at(y.at(i)-1) = v.at(i); } ll ans = 0; rep(i,h){ rep(j,w){ rep(a,h){ rep(b,w){ if(a+b>=i+j && a-b>=i-j) ans += g.at(a).at(b); ans %= MOD; } } } } cout << ans << endl; }