#include <bits/stdc++.h>
using namespace std;
map<long long, pair<long long, long long> > row, col;
map<long long, bool> brow, bcol;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k, i, j, x, y, z;
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    cin >> x >> y >> z;
    if (x == 1) {
      row[y] = make_pair(z, i);
      brow[y] = true;
    } else if (x == 2) {
      col[y] = make_pair(z, i);
      bcol[y] = true;
    }
  }
  pair<long long, long long> t1, t2;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (!brow[i] && !bcol[j]) {
        cout << "0 ";
      } else if (!brow[i] && bcol[j]) {
        t1 = col[j];
        cout << t1.first << " ";
      } else if (brow[i] && !bcol[j]) {
        t1 = row[i];
        cout << t1.first << " ";
      } else {
        t1 = row[i];
        t2 = col[j];
        if (t1.second > t2.second) {
          cout << t1.first << " ";
        } else {
          cout << t2.first << " ";
        }
      }
    }
    cout << endl;
  }
  return 0;
}
