#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, kind, pos, clr;
  cin >> n >> m >> k;
  vector<pair<int, int>> row(n + 2), col(m + 2);
  for (int i = 0; i < k; i++) {
    cin >> kind >> pos >> clr;
    if (kind == 1) {
      row[pos].first = clr;
      row[pos].second = i + 1;
    } else {
      col[pos].first = clr;
      col[pos].second = i + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (row[i].second > col[j].second)
        cout << row[i].first << " ";
      else
        cout << col[j].first << " ";
    }
    cout << "\n";
  }
}
