#include <bits/stdc++.h>
using namespace std;
int n, m, k;
pair<int, int> row[5002];
pair<int, int> col[5002];
int main(int argc, char **argv) {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int op, r, color;
    scanf("%d%d%d", &op, &r, &color);
    if (op == 1) {
      row[r] = make_pair(i, color);
    } else {
      col[r] = make_pair(i, color);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; ++j) {
      pair<int, int> pr = row[i];
      pair<int, int> pc = col[j];
      if (pr.first == 0 && pc.first == 0)
        printf("%d ", 0);
      else if (pr.first < pc.first) {
        printf("%d ", pc.second);
      } else if (pr.first > pc.first) {
        printf("%d ", pr.second);
      } else {
        printf("%d ", 0);
      }
    }
    printf("\n");
  }
  return 0;
}
