#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535;
long long powi(long long base, int p) {
  long long res = 1;
  while (p--) res *= base;
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
bool is_vowel(char c) {
  c = tolower(c);
  return c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u' || c == 'y';
}
pair<int, int> row[5001];
pair<int, int> col[5001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 5001; i++) {
    row[i] = {0, 0};
    col[i] = {0, 0};
  }
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1, q, r, c, a; i <= k; i++) {
    cin >> q;
    if (q == 1) {
      cin >> r >> a;
      row[r - 1] = {i, a};
    } else {
      cin >> c >> a;
      col[c - 1] = {i, a};
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      cout << (row[i] > col[j] ? row[i].second : col[j].second) << ' ';
    cout << '\n';
  }
  return 0;
}
