#include <bits/stdc++.h>
using namespace std;
int s[5009][5009];
int n, m, k;
vector<pair<pair<int, int>, int> > v;
set<int> r[5009], c[5009];
bool hr[5009], hc[5009];
int main() {
  cin >> n >> m >> k;
  while (k--) {
    int t, x, a;
    scanf("%d%d%d", &t, &x, &a);
    v.push_back(make_pair(make_pair(x, a), t));
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) r[i].insert(j);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) c[i].insert(j);
  for (int i = v.size() - 1; i >= 0; i--) {
    int ch = v[i].second;
    int pos = v[i].first.first;
    int cl = v[i].first.second;
    if (ch == 1) {
      if (hr[pos]) continue;
      for (set<int>::iterator it = r[pos].begin(); it != r[pos].end(); it++) {
        s[pos][*it] = cl;
        if (c[*it].find(pos) != c[*it].end()) c[*it].erase(pos);
      }
      hr[pos] = 1;
    } else {
      if (hc[pos]) continue;
      for (set<int>::iterator it = c[pos].begin(); it != c[pos].end(); it++) {
        s[*it][pos] = cl;
        if (r[*it].find(pos) != r[*it].end()) r[*it].erase(pos);
      }
      hc[pos] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << s[i][j] << " ";
    cout << endl;
  }
  return 0;
}
