#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ifstream ifs("workspacetop.txt"); using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using namespace std; using ll = long long; static const double pi = 3.141592653589793; const int INF = (1<<29); const ll mod = 998244353; int main(){ int h,w,k; cin >> h >> w >> k; vector table(h,vector(w,0)); for(int i=0;i> x >> y >> v; x--;y--; table[x][y] = v; } mint ans = 0; for(int i=0;i=i+j && x-y>=i-j){ ans += table[x][y]; } } } } } cout << ans.val() << endl; }