#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[5005][5005];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  set<pair<int, int> > se;
  for (int i = 0; i < k; i++) {
    int u, v, p;
    cin >> u >> v >> p;
    if (u == 1) {
      a[v][0].first = p;
      a[v][0].second = i + 1;
    } else {
      a[0][v].first = p;
      a[0][v].second = i + 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      a[j][i].first = a[0][i].first;
      a[j][i].second = a[0][i].second;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if ((a[i][j].second < a[i][0].second)) {
        a[i][j].first = a[i][0].first;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << a[i][j].first << " ";
    }
    cout << "\n";
  }
}
