#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; int main(){ int H,W,K; cin>>H>>W>>K; vector> grid(H,vector(W,0)); vector x(K),y(K); vector v(K); for(int k=0;k>x[k]>>y[k]>>v[k]; x[k]--;y[k]--; grid[x[k]][y[k]]=v[k]; } ll ans=0; for(int i=0;i=(i+j) && (x-y)>=(i-j)){ ans+=grid[x][y]; ans%=MOD; } } } } } cout<