#include <bits/stdc++.h>
using namespace std;
pair<int, int> r[5005];
pair<int, int> c[5005];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int op, rc, c1;
  for (int i = 0; i < 5005; ++i) {
    r[i] = pair<int, int>(0, 0);
    c[i] = pair<int, int>(0, 0);
  }
  for (int i = 0; i < k; ++i) {
    cin >> op >> rc >> c1;
    --rc;
    if (op == 1)
      r[rc].first = i, r[rc].second = c1;
    else
      c[rc].first = i, c[rc].second = c1;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (j) cout << ' ';
      if (!r[i].second)
        cout << c[j].second;
      else if (!c[j].second)
        cout << r[i].second;
      else if (c[j].first < r[i].first)
        cout << r[i].second;
      else
        cout << c[j].second;
    }
    cout << '\n';
  }
}
