func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<pair<int, int>, int> a[100001];   pair<int, int> ans[100001];   int n, m, i, j, k, l, r, t, last, b[100001], x, y;   map<int, pair<int, int> > mp;   int main() {     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> a[i].first.first >> a[i].first.second;       a[i].first.second = 1 - a[i].first.second;       b[i] = a[i].first.first;       a[i].second = i;     }     sort(a, a + m);     if (a[0].first.second || a[1].first.second) {       cout << -1;       return 0;     }     k = 3;     for (i = 2; i < m; i++) {       if (a[i].first.second) {         if (t == (k - 2) * (k - 1) / 2) {           cout << -1;           return 0;         }         t++;         continue;       }       k++;     }     t = 2;     for (i = 0; i < m; i++) {       if (!a[i].first.second) {         ans[a[i].second].first = t - 1;         ans[a[i].second].second = t;         t++;       }     }     x = 3;     y = 1;     for (i = 0; i < m; i++) {       if (!a[i].first.second) continue;       ans[a[i].second].first = y;       ans[a[i].second].second = x;       y++;       if (x == y + 1) {         x++;         y = 1;       }     }     for (i = 0; i < m; i++) {       cout << ans[i].first <<     << ans[i].second << endl;     }   }   