#include #include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double dd; typedef unsigned long long ull; typedef vector vl; typedef vector
vd; typedef vector vb; typedef vector> vl_l; typedef vector> vvl; typedef vector> vvd; typedef vector> vvb; typedef vector>> vvl_l; typedef vector>> vvvl; typedef vector>> vvvd; typedef vector>> vvvb; typedef vector>>> vvvl_l; typedef map ml; typedef set sl; // #define i_7 (ll)(1E9+7) #define i_7 998244353 #define i_5 i_7-2 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; return c+i_7; } typedef pair l_l; typedef pair d_d; ll inf=(ll)1E18; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(ab)return b;else return a;} dd EPS=1E-9; dd PI=acos(-1); // #define endl "\n" #define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); template inline bool chmax(T &a, S b) { if(a < b) { a = (T)b; return true; } return false; } template inline bool chmin(T &a, S b) { if(a > b) { a = (T)b; return true; } return false; } ll hpow(ll x,ll y){ if(y==0)return 1; ll res=hpow(x,y/2); res = mod(res*res); if(y%2==1){ res *= x; res = mod(res); } return mod(res); } ll hpow_m(ll x,ll y,ll m){ if(y==0)return 1; ll res=hpow_m(x,y/2,m); res = (res*res)%m; if(y%2==1){ res *= x; res %= m; } return res%m; } signed main(){fastio ll h,w;cin>>h>>w; ll k;cin>>k; map mp; rep(i,1,k){ ll x,y,v;cin>>x>>y>>k; mp[l_l(x, y)] = k; } ll ans = 0; rep(i,1,h){ rep(j,1,w){ rep(x,1,h){ rep(y,1,w){ if(x + y >= i + j && x - y >= i - j){ ans += mp[l_l(x, y)]; ans = mod(ans); } } } } } cout << ans << endl; return 0; }