#include <bits/stdc++.h>
using namespace std;
pair<long long, int> strin[5 * int(1e3) + 4];
pair<long long, int> stlb[5 * int(1e3) + 4];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; ++i) {
    int x, number;
    long long color;
    cin >> x >> number >> color;
    if (x == 1) {
      strin[number] = make_pair(color, i);
    } else
      stlb[number] = make_pair(color, i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int g = 1; g <= m; ++g) {
      if (strin[i].second > stlb[g].second)
        cout << strin[i].first << " ";
      else
        cout << stlb[g].first << " ";
    }
    cout << endl;
  }
  return 0;
}
