#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, z;
pair<int, int> a[5555], b[5555];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y >> z;
    y--;
    if (x == 1)
      a[y] = make_pair(z, i + 1);
    else
      b[y] = make_pair(z, i + 1);
  }
  for (int i = 0; i < n; i++) {
    cout << "\n";
    for (int q = 0; q < m; q++) {
      if (a[i].second >= b[q].second)
        cout << a[i].first << " ";
      else
        cout << b[q].first << " ";
    }
  }
}
