#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;
const int inf = 9999999;
const int mod = 1e9 + 7;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int kr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int kc[] = {-2, -2, -1, 1, 2, 2, -1, 1};
int dgr[] = {-1, -1, 1, 1};
int dgc[] = {1, -1, -1, 1};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<tpl> v;
  for (int i = 0; i < k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v.push_back({a, b, c});
  }
  map<int, int> row, col;
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  vector<tpl> ans;
  for (int i = k - 1; i >= 0; i--) {
    int a, b, c;
    a = get<0>(v[i]), b = get<1>(v[i]), c = get<2>(v[i]);
    if (a == 1) {
      if (!row[b]) {
        row[b] = 1;
        ans.push_back({a, b, c});
      }
    } else {
      if (!col[b]) {
        col[b] = 1;
        ans.push_back({a, b, c});
      }
    }
  }
  for (int i = ans.size() - 1; i >= 0; i--) {
    int a, b, c;
    a = get<0>(ans[i]), b = get<1>(ans[i]), c = get<2>(ans[i]);
    if (a == 1) {
      fill(dp[b - 1].begin(), dp[b - 1].end(), c);
    } else {
      for (int i = 0; i < n; i++) dp[i][b - 1] = c;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}
