#include <bits/stdc++.h>
using namespace std;
int a, b, c, type, x, y;
pair<int, int> d[100009], g[100009];
vector<pair<int, pair<int, int> > > v, v1;
int h[5009][5009];
int main() {
  cin >> a >> b >> c;
  for (int i = 1; i <= c; i++) {
    cin >> type >> x >> y;
    if (type == 1) d[x] = make_pair(i, y);
    if (type == 2) g[x] = make_pair(i, y);
  }
  for (int i = 1; i <= 5000; i++) {
    if (d[i].first > 0)
      v.push_back(make_pair(d[i].first, make_pair(i, d[i].second)));
    if (g[i].first > 0)
      v1.push_back(make_pair(g[i].first, make_pair(i, g[i].second)));
  }
  sort(v.begin(), v.end());
  sort(v1.begin(), v1.end());
  int x = 0;
  int y = 0;
  while (x < v.size() or y < v1.size()) {
    if (x < v.size()) {
      if (y < v1.size()) {
        if (v1[y].first > v[x].first) {
          for (int j = 1; j <= b; j++)
            h[v[x].second.first][j] = v[x].second.second;
          x++;
        } else {
          for (int j = 1; j <= a; j++)
            h[j][v1[y].second.first] = v1[y].second.second;
          y++;
        }
      } else {
        for (int j = 1; j <= b; j++)
          h[v[x].second.first][j] = v[x].second.second;
        x++;
      }
    } else {
      for (int j = 1; j <= a; j++)
        h[j][v1[y].second.first] = v1[y].second.second;
      y++;
    }
  }
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) cout << h[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
