#include using namespace std; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int H, W, K; cin >> H >> W >> K; long long ret = 0; while (K--) { int x, y, v; cin >> x >> y >> v; for (int i = 1; i <= H; ++i) { for (int j = 1; j <= W; ++j) { if (x + y >= i + j and x - y >= i - j) ret += v; } } } cout << ret % 998244353 << endl; }