#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a, b, cc;
  int r[5007], c[5007];
  int final[n + 1][m + 1];
  int nor[5007], noc[5007];
  for (int i = 0; i < 5001; i++) {
    r[i] = 0;
    c[i] = 0;
    nor[i] = 0;
    noc[i] = 0;
  }
  int po = 1;
  for (int i = 0; i < k; i++) {
    cin >> a >> b >> cc;
    if (a == 1) {
      r[b] = cc;
      nor[b] = po;
    } else if (a == 2) {
      c[b] = cc;
      noc[b] = po;
    }
    po++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (nor[i] > noc[j]) {
        final[i][j] = r[i];
      } else if (nor[i] < noc[j]) {
        final[i][j] = c[j];
      } else {
        final[i][j] = 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << final[i][j] << " ";
    }
    cout << endl;
  }
}
