#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000 + 50;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
int row[MAX_N];
int col[MAX_N];
int op[MAX_N];
int main() {
  int n, m;
  int k;
  scanf("%d%d%d", &n, &m, &k);
  op[0] = 0;
  int t, p;
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d", &t, &p, &op[i]);
    if (t == 1)
      row[p] = i;
    else
      col[p] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d%c", op[max(row[i], col[j])], j == m ? '\n' : ' ');
    }
  }
  return 0;
}
