#include <bits/stdc++.h>
using namespace std;
int coulmn[5000][2], row[5000][2];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int casee, index, value;
    cin >> casee >> index >> value;
    if (casee == 1) {
      row[index][0] = value;
      row[index][1] = i;
    } else {
      coulmn[index][0] = value;
      coulmn[index][1] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (row[i][1] > coulmn[j][1]) {
        cout << row[i][0] << " ";
      } else {
        cout << coulmn[j][0] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
