#include <bits/stdc++.h>
using namespace std;
int arr[6000][6000];
pair<int, int> row[6000];
pair<int, int> col[6000];
int main() {
  memset(arr, 0, sizeof(arr));
  int n, m, k;
  int t = 1;
  cin >> n >> m >> k;
  int i, j;
  int ch;
  int r, c, a;
  for (i = 0; i < k; i++) {
    cin >> ch;
    if (ch == 1) {
      cin >> r >> a;
      row[r] = make_pair(a, t);
      t++;
    } else {
      cin >> c >> a;
      col[c] = make_pair(a, t);
      t++;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (row[i].second > col[j].second) {
        arr[i][j] = row[i].first;
      } else if (col[j].second > row[i].second) {
        arr[i][j] = col[j].first;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cout << arr[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
