#include <bits/stdc++.h>
using namespace std;
pair<int, int> row[5005];
pair<int, int> col[5005];
pair<int, int> arr[5005][5005];
int main() {
  int t1, t2, t3;
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i < 5005; i++) {
    row[i] = make_pair(0, 0);
    col[i] = make_pair(0, 0);
  }
  int tim = 1;
  for (int i = 0; i < k; i++) {
    cin >> t1 >> t2 >> t3;
    if (t1 == 1) {
      row[t2] = make_pair(tim, t3);
    } else {
      col[t2] = make_pair(tim, t3);
    }
    tim++;
  }
  int c, tt;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      arr[i][j] = row[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    c = col[i].second;
    tt = col[i].first;
    for (int j = 1; j <= n; j++) {
      if (arr[j][i].first < tt) arr[j][i] = col[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << arr[i][j].second << " ";
    }
    cout << endl;
  }
}
