#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return b * a / gcd(a, b);
}
long long int abs1(long long int a) {
  if (a < 0)
    return -1 * a;
  else
    return a;
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int fast_pow(long long base, long long n, long long M) {
  if (n == 0) return 1;
  if (n == 1) return base;
  long long halfn = fast_pow(base, n / 2, M);
  if (n % 2 == 0)
    return (halfn * halfn) % M;
  else
    return (((halfn * halfn) % M) * base) % M;
}
long long int findMMI_fermat(long long int n, long long int M) {
  return fast_pow(n, M - 2, M);
}
const double PI = 3.14159265358979323846;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  int count = 1;
  map<int, pair<int, int> > row, column;
  while (k--) {
    int r, s, t;
    cin >> r >> s >> t;
    if (r == 1) {
      row[s] = make_pair(t, count);
    } else {
      column[s] = make_pair(t, count);
    }
    count++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (row[i].first == 0 && column[j].first == 0) {
        cout << "0 ";
        continue;
      }
      int r = row[i].second;
      int l = column[j].second;
      if (r > l) {
        cout << row[i].first << " ";
      } else {
        cout << column[j].first << " ";
      }
    }
    cout << '\n';
  }
  return 0;
}
