#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = ((ans % 1000000007) * (a % 1000000007)) % 1000000007;
    }
    a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
    b >>= 1;
  }
  return ans;
}
long long int mina(long long int arr[], int n) {
  long long int x = arr[0], i;
  int pos = 0;
  for (i = 1; i < n; i++)
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  return x;
}
long long int maxa(long long int arr[], int n) {
  long long int x = arr[0], i;
  int pos = 0;
  for (i = 1; i < n; i++)
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  return x;
}
int main() {
  int n, m, k, i, j, co, x, ch;
  vector<pair<int, int> > r, c;
  r.resize(100005);
  c.resize(100005);
  cin >> n >> m >> k;
  for (i = 0; i < k; i++) {
    cin >> ch >> x >> co;
    if (ch == 1) {
      r[x - 1].second = i + 1;
      r[x - 1].first = co;
    } else {
      c[x - 1].second = i + 1;
      c[x - 1].first = co;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (r[i].second > c[j].second)
        cout << r[i].first << " ";
      else
        cout << c[j].first << " ";
    }
    cout << endl;
  }
  return 0;
}
