#include <bits/stdc++.h>
using namespace std;
template <class T>
void max_self(T& a, const T& b) {
  if (a < b) a = b;
}
template <class T>
void min_self(T& a, const T& b) {
  if (a > b) a = b;
}
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
int N, M, k;
pair<int, int> grid[5005][5005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> N >> M >> k;
  for (int r = 0; r <= N; ++r) {
    grid[r][0] = make_pair(0, 0);
  }
  for (int c = 0; c <= M; ++c) {
    grid[0][c] = make_pair(0, 0);
  }
  for (int rep = 1, x, y, z; rep <= k; ++rep) {
    cin >> x >> y >> z;
    if (x == 1)
      grid[y][0] = make_pair(z, rep);
    else
      grid[0][y] = make_pair(z, rep);
  }
  for (int c = 1, col, o; c <= M; ++c) {
    col = grid[0][c].first, o = grid[0][c].second;
    for (int r = 1; r <= N; ++r) {
      grid[r][c].first = col;
      grid[r][c].second = o;
    }
  }
  for (int r = 1, col, o; r <= N; cout << '\n', ++r) {
    col = grid[r][0].first, o = grid[r][0].second;
    for (int c = 1; c <= M; ++c) {
      if (o > grid[r][c].second)
        cout << col << " ";
      else
        cout << grid[r][c].first << " ";
    }
  }
  return 0;
}
