#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 17, N1 = 5e3 + 17;
int n, m, k;
struct nd {
  int x, i, c;
};
nd a[N];
vector<nd> v1;
bool used[3][N1];
int ans[N1][N1];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int x, ind, color;
    cin >> x >> ind >> color;
    a[i].x = x;
    a[i].i = ind;
    a[i].c = color;
  }
  for (int i = k; i >= 1; i--) {
    int x = a[i].x;
    int v = a[i].i;
    if (!used[x][v]) {
      used[x][v] = true;
      v1.push_back(a[i]);
    }
  }
  for (int i = v1.size() - 1; i >= 0; i--) {
    int x = v1[i].x;
    int v = v1[i].i;
    int color = v1[i].c;
    if (x == 1) {
      for (int i = 1; i <= m; i++) {
        ans[v][i] = color;
      }
    } else {
      for (int i = 1; i <= n; i++) {
        ans[i][v] = color;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
