#include <bits/stdc++.h>
using namespace std;
int main() {
  int height = 0;
  cin >> height;
  int width = 0;
  cin >> width;
  int actions = 0;
  cin >> actions;
  vector<pair<int, int>> horizontal(width, make_pair(0, -1));
  vector<pair<int, int>> vertical(height, make_pair(0, -1));
  for (int i = 0; i < actions; i++) {
    int action = 0;
    cin >> action;
    int coord = 0;
    cin >> coord;
    coord--;
    int colour = 0;
    cin >> colour;
    if (action == 1) {
      vertical[coord] = make_pair(colour, i);
    } else if (action == 2) {
      horizontal[coord] = make_pair(colour, i);
    }
  }
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      if (horizontal[j].second > vertical[i].second)
        cout << horizontal[j].first << " ";
      else
        cout << vertical[i].first << " ";
    }
    cout << endl;
  }
  return 0;
}
