#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  vector<vector<int> > a(n + 1, vector<int>(m + 1, 0)),
      q(k + 1, vector<int>(3));
  set<int> r, c;
  for (int i = 1; i <= n; i++) r.insert(i);
  for (int i = 1; i <= m; i++) c.insert(i);
  for (int i = k; i > 0; i--)
    for (int j = 0; j < 3; j++) scanf("%d", &q[i][j]);
  for (int i = 1; i <= k; i++) {
    if (q[i][0] == 1 && r.find(q[i][1]) != r.end()) {
      for (int j : c) a[q[i][1]][j] = q[i][2];
      r.erase(q[i][1]);
    } else if (q[i][0] == 2 && c.find(q[i][1]) != c.end()) {
      for (int j : r) a[j][q[i][1]] = q[i][2];
      c.erase(q[i][1]);
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) printf(j == m ? "%d\n" : "%d ", a[i][j]);
}
