#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = int(1e9);
const int MAX = 5005;
int n, m, k;
int board[MAX][MAX];
int row[MAX], col[MAX];
void fillRow(int r, int c) {
  for (int j = 1; j <= m; j++) {
    if (board[r][j] == -1) {
      board[r][j] = c;
    }
  }
}
void fillCol(int col, int c) {
  for (int i = 1; i <= n; i++) {
    if (board[i][col] == -1) {
      board[i][col] = c;
    }
  }
}
struct query {
  int type;
  int target;
  int colour;
} p[100007];
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = 0; i < MAX; i++) {
    row[i] = col[i] = -1;
  }
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      board[i][j] = -1;
    }
  }
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> p[i].type >> p[i].target >> p[i].colour;
  }
  for (int i = k; i >= 1; i--) {
    if (p[i].type == 1) {
      if (row[p[i].target] == -1) {
        row[p[i].target] = p[i].colour;
        fillRow(p[i].target, p[i].colour);
      }
    } else {
      if (col[p[i].target] == -1) {
        col[p[i].target] = p[i].colour;
        fillCol(p[i].target, p[i].colour);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (board[i][j] == -1) {
        board[i][j] = 0;
      }
      cout << board[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
