#include <bits/stdc++.h>
using namespace std;
struct query {
  long long type;
  long long loc;
  long long color;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long>> board(n, vector<long long>(m, 0));
  vector<query> queries(k);
  for (int i = 0; i < k; i++)
    cin >> queries[i].type >> queries[i].loc >> queries[i].color;
  unordered_set<long long> ur, uc;
  for (int i = k - 1; i >= 0; i--) {
    query q = queries[i];
    if (q.type == 1) {
      if (ur.find(q.loc) == ur.end()) {
        ur.insert(q.loc);
        for (int i = 0; i < m; i++)
          if (board[q.loc - 1][i] == 0) board[q.loc - 1][i] = q.color;
      }
    } else {
      if (uc.find(q.loc) == uc.end()) {
        uc.insert(q.loc);
        for (int i = 0; i < n; i++)
          if (board[i][q.loc - 1] == 0) board[i][q.loc - 1] = q.color;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << board[i][j] << " ";
    }
    cout << '\n';
  }
}
