#include <bits/stdc++.h>
using namespace std;
long long int ty[100010], rc[100010], x[100010];
long long int row[5010], col[5010];
long long int ans[5010][5010];
vector<pair<long long int, long long int> > v;
int main() {
  long long int n, m, k, i, j, a, b, c;
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    cin >> ty[i] >> rc[i] >> x[i];
  }
  for (i = k; i > 0; i--) {
    a = ty[i];
    b = rc[i];
    c = x[i];
    if (a == 1) {
      if (!row[b]) {
        row[b] = c;
        v.push_back(make_pair(1, b));
      }
    }
    if (a == 2) {
      if (!col[b]) {
        col[b] = c;
        v.push_back(make_pair(2, b));
      }
    }
  }
  pair<long long int, long long int> p;
  for (i = 0; i < v.size(); i++) {
    p = v[i];
    a = p.first;
    b = p.second;
    if (a == 1) {
      for (j = 1; j <= m; j++) {
        if (ans[b][j] == 0) ans[b][j] = row[b];
      }
    }
    if (a == 2) {
      for (j = 1; j <= n; j++) {
        if (ans[j][b] == 0) ans[j][b] = col[b];
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j < m; j++) {
      cout << ans[i][j] << " ";
    }
    cout << ans[i][m] << endl;
  }
  return 0;
}
