func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long mod = 1e9 + 7;   const long long N = 1e5 + 10;   struct node {     int ind, type, row, color;     node(int a, int b, int c, int d) {       ind = a;       type = b;       row = c;       color = d;     }   };   bool comp(node x, node y) { return x.ind < y.ind; }   int main() {     ios::sync_with_stdio(false);     int n, m, k;     cin >> n >> m >> k;     vector<vector<int> > ans(n, vector<int>(m, 0));     vector<vector<pair<int, int> > > v(2, vector<pair<int, int> >(max(n, m)));     for (int i = 0; i < k; i++) {       int a, b, c;       cin >> a >> b >> c;       v[a - 1][b - 1] = make_pair(i, c);     }     vector<node> vec;     for (int i = 0; i < 2; i++)       for (int j = 0; j < max(n, m); j++)         if (v[i][j].second != 0)           vec.push_back(node(v[i][j].first, i, j, v[i][j].second));     sort(vec.begin(), vec.end(), comp);     for (int i = 0; i < vec.size(); i++) {       if (vec[i].type == 0) {         for (int j = 0; j < m; j++) ans[vec[i].row][j] = vec[i].color;       } else {         for (int j = 0; j < n; j++) ans[j][vec[i].row] = vec[i].color;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cout << ans[i][j] <<    ;       cout << endl;     }     return 0;   }   