#include <bits/stdc++.h>
using namespace std;
int row[5001] = {0};
int rowt[5001] = {0};
int col[5001] = {0};
int colt[5001] = {0};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int q, t, a;
  for (int i = 1; i < k + 1; i++) {
    cin >> q >> t >> a;
    t--;
    if (q == 1) {
      row[t] = a;
      rowt[t] = i;
    }
    if (q == 2) {
      col[t] = a;
      colt[t] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (colt[j] > rowt[i])
        cout << col[j] << " ";
      else
        cout << row[i] << " ";
    }
    cout << endl;
  }
}
