#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int n, m, k;
int cmd[MAXN][5];
bool x[5005], y[5005];
int gra[5005][5005];
int main() {
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    for (int i = 1; i <= k; ++i) {
      scanf("%d%d%d", &cmd[i][1], &cmd[i][2], &cmd[i][3]);
    }
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    memset(gra, 0, sizeof(gra));
    for (int i = k; i > 0; --i) {
      if (cmd[i][1] == 1 && !x[cmd[i][2]]) {
        x[cmd[i][2]] = true;
        for (int j = 1; j <= m; ++j) {
          if (!gra[cmd[i][2]][j]) gra[cmd[i][2]][j] = cmd[i][3];
        }
      } else if (cmd[i][1] == 2 && !y[cmd[i][2]]) {
        y[cmd[i][2]] = true;
        for (int j = 1; j <= n; ++j) {
          if (!gra[j][cmd[i][2]]) gra[j][cmd[i][2]] = cmd[i][3];
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        printf("%d%c", gra[i][j], j == m ? '\n' : ' ');
      }
    }
  }
  return 0;
}
