#include <bits/stdc++.h>
using namespace std;
long long int stringtoLLI(string str) {
  long long int val;
  stringstream ss;
  ss << str;
  ss >> val;
  return val;
}
string LLItostring(long long int val) {
  string str;
  stringstream ss;
  ss << val;
  ss >> str;
  return str;
}
long long int ar[5009][5009];
long long int n, m, fst[5009], snd[5009], l;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  string str;
  while (cin >> n >> m >> l) {
    long long int x, y, z;
    for (int i = 1; i <= l; i++) {
      cin >> x >> y >> z;
      if (x == 1) {
        ar[y][0] = z;
        fst[y] = i;
      } else if (x == 2) {
        ar[0][y] = z;
        snd[y] = i;
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (fst[i] >= snd[j]) {
          cout << ar[i][0] << " ";
        } else {
          cout << ar[0][j] << " ";
        }
      }
      cout << endl;
    }
  }
  return 0;
}
