func_code_string: #include <bits/stdc++.h>   using namespace std;   const int NMAX = (int)(1e5) + 10;   int n, m, a, b;   vector<pair<int, pair<int, int> > > ed;   pair<int, int> res[NMAX];   int last;   int now[NMAX];   bool func(pair<int, pair<int, int> > i, pair<int, pair<int, int> > j) {     if (i.first == j.first)       return (i.second.first > j.second.first);     else       return (i.first < j.first);   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d %d , &a, &b);       ed.push_back(make_pair(a, make_pair(b, i)));     }     sort(ed.begin(), ed.end(), func);     int i = 1;     last = 1;     for (int kk = 0; kk <= (int)ed.size() - 1; kk++) {       int val = ed[kk].first;       int type = ed[kk].second.first;       int vt = ed[kk].second.second;       if (type == 1) {         res[vt] = make_pair(last, 1 + last);         last++;         now[last] = last;       } else {         bool co = 0;         while (!co) {           for (int j = min(i - 2, now[i] - 1); j >= 1; j--) {             res[vt] = make_pair(j, i);             co = 1;             now[i] = j;             break;           }           if (!co) i++;           if (i > last) {             cout << -1;             return 0;           }         }       }     }     if (last != n) {       cout << -1;       return 0;     }     for (int i = 1; i <= m; i++)       cout << res[i].first <<     << res[i].second << endl;   }   