#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000;
int n, m, k, ans[MAXN][MAXN];
bool was[2][MAXN];
pair<int, pair<int, int> > q[20 * MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  while (cin >> n >> m >> k) {
    memset(ans, 0, sizeof ans);
    memset(was, 0, sizeof was);
    for (int i = 0; i < k; ++i) {
      int op, r, a;
      cin >> op >> r >> a;
      --op, --r;
      q[i] = {op, {r, a}};
    }
    for (int i = k - 1; i >= 0; --i) {
      int op = q[i].first, r = q[i].second.first, a = q[i].second.second;
      if (!was[op][r]) {
        if (op == 0) {
          for (int j = 0; j < m; ++j)
            if (ans[r][j] == 0) ans[r][j] = a;
        } else {
          for (int j = 0; j < n; ++j)
            if (ans[j][r] == 0) ans[j][r] = a;
        }
      }
      was[op][r] = 1;
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cout << ans[i][j] << ' ';
      }
      cout << '\n';
    }
  }
  return 0;
}
