#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int rowColor[5000];
  int rowPaintedAt[5000];
  int colColor[5000];
  int colPaintedAt[5000];
  for (int i = 0; i < n; i++) {
    rowColor[i] = 0;
    rowPaintedAt[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    colColor[i] = 0;
    colPaintedAt[i] = 0;
  }
  for (int i = 1; i <= k; i++) {
    int operation;
    cin >> operation;
    if (operation == 1) {
      int r, color;
      cin >> r >> color;
      r--;
      rowColor[r] = color;
      rowPaintedAt[r] = i;
    } else {
      int c, color;
      cin >> c >> color;
      c--;
      colColor[c] = color;
      colPaintedAt[c] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (rowPaintedAt[i] > colPaintedAt[j]) {
        cout << rowColor[i];
      } else {
        cout << colColor[j];
      }
      if (j < m - 1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}
