#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
pair<int, int> row[5005];
pair<int, int> col[5005];
int ans[5005][5005];
int main() {
  int n, m, k, a, b, c;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> a >> b >> c;
    if (a == 1) {
      row[b] = {i, c};
    } else {
      col[b] = {i, c};
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (col[j].first > row[i].first)
        cout << col[j].second << " ";
      else
        cout << row[i].second << " ";
    }
    cout << endl;
  }
}
