func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5;   int from[N], to[N];   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     vector<pair<int, int> > mst;     set<pair<int, int> > freeEdges;     for (int i = 0; i < (int)(m); ++i) {       int w, isMST;       cin >> w >> isMST;       if (isMST) {         mst.push_back(make_pair(w, i));       } else {         freeEdges.insert(make_pair(w, i));       }     }     sort(mst.begin(), mst.end());     for (int i = 0; i < (int)(n - 1); ++i) {       int id = mst[i].second;       from[id] = i;       to[id] = i + 1;     }     int u = 0, v = 2;     for (int i = 0; i < (int)(m - n + 1); ++i) {       int cur = mst[v - 1].first;       auto it = freeEdges.lower_bound(make_pair(cur, -1));       if (freeEdges.empty() || it == freeEdges.end()) {         cout << -1;         return 0;       }       int id = it->second;       from[id] = u;       to[id] = v;       --u;       if (u == -1) {         u = v - 1;         ++v;       }       freeEdges.erase(it);     }     for (int i = 0; i < (int)(m); ++i) {       cout << 1 + from[i] <<     << 1 + to[i] << endl;     }     return 0;   }   