#include <bits/stdc++.h>
using namespace std;
int n, m, q, tep1, tep2, tep3;
int c[1000001], l[1000001], num[1000001];
bool hang[1000001], lie[1000001];
int mp[5001][5001];
int now, fh;
char ch;
inline int get_num() {
  now = 0;
  fh = 1;
  ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    now = (now << 3) + (now << 1) + ch - '0';
    ch = getchar();
  }
  return now * fh;
}
int main() {
  n = get_num();
  m = get_num();
  q = get_num();
  for (int i = 1; i <= q; i++) {
    c[i] = get_num();
    l[i] = get_num();
    num[i] = get_num();
  }
  for (int i = q; i >= 1; i--) {
    if (c[i] == 1 && hang[l[i]] != 1) {
      for (int j = 1; j <= m; j++) {
        if (mp[l[i]][j] != 0) continue;
        mp[l[i]][j] = num[i];
      }
      hang[l[i]] = 1;
    }
    if (c[i] == 2 && lie[l[i]] != 1) {
      for (int j = 1; j <= n; j++) {
        if (mp[j][l[i]] != 0) continue;
        mp[j][l[i]] = num[i];
      }
      lie[l[i]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", mp[i][j]);
    }
    putchar('\n');
  }
  return 0;
}
