#include <bits/stdc++.h>
using namespace std;
int print(vector<int> s) {
  int n = s.size();
  for (int i = 0; i < n; i++) cout << s[i] << " ";
  cout << endl;
  return 0;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int> > vert(m);
  vector<vector<int> > gor(n);
  vector<int> c(2);
  c[0] = -1;
  c[1] = -1;
  for (int i = 0; i < m; i++) vert[i] = c;
  for (int i = 0; i < n; i++) gor[i] = c;
  for (int i = 0; i < k; i++) {
    int t, r, a;
    cin >> t >> r >> a;
    if (t == 1) {
      gor[r - 1][0] = a;
      gor[r - 1][1] = i;
    } else {
      vert[r - 1][1] = i;
      vert[r - 1][0] = a;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int t = -1;
      int a = 0;
      if (gor[i][1] > t) {
        a = gor[i][0];
        t = gor[i][1];
      }
      if (vert[j][1] > t) {
        a = vert[j][0];
      }
      cout << a << " ";
    }
    cout << endl;
  }
  return 0;
}
