#include <bits/stdc++.h>
using namespace std;
long n, m, a[10000] = {0}, b[10000] = {0}, k, u[200000], v[200000], w[200000],
           f[5010][5010] = {0};
int main() {
  cin >> n >> m >> k;
  for (long i = 0; i < k; i++) cin >> u[i] >> v[i] >> w[i];
  for (long i = k - 1; i >= 0; i--) {
    if (u[i] == 1) {
      if (a[v[i]] == 0) {
        for (long j = 1; j <= m; j++)
          if (f[v[i]][j] == 0) f[v[i]][j] = w[i];
        a[v[i]] = 1;
      }
    } else {
      if (b[v[i]] == 0) {
        for (long j = 1; j <= n; j++)
          if (f[j][v[i]] == 0) f[j][v[i]] = w[i];
        b[v[i]] = 1;
      }
    }
  }
  for (long i = 1; i <= n; i++) {
    for (long j = 1; j <= m; j++) cout << f[i][j] << " ";
    cout << endl;
  }
}
