func_code_string: #include <bits/stdc++.h>   using namespace std;   int safeop(int n, int mod) { return (n + mod) % mod; }   int main() {     int n;     cin >> n;     vector<int> v(n, 0);     vector<pair<int, int>> ans(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     int vn = n;     int v1 = -1;     stack<int> bal1;     stack<int> bal2;     stack<int> bal3;     for (int i = 0; i < n; i++) {       if (v[i] == 3) {         if (vn - v1 == 1) {           cout << -1;           return 0;         }         vn--;         ans[i] = make_pair(vn, -1);         if (!bal3.empty()) {           int tmp = bal3.top();           bal3.pop();           ans[tmp].second = i;           bal3.push(i);         } else {           bal3.push(i);         }       } else if (v[i] == 2) {         if (vn - v1 == 1) {           cout << -1;           return 0;         }         v1++;         ans[i] = make_pair(v1, -1);         if (!bal3.empty()) {           int tmp = bal3.top();           bal3.pop();           ans[tmp].second = i;           bal2.push(i);         } else {           bal2.push(i);         }       } else if (v[i] == 1) {         if (!bal2.empty()) {           int tmp = bal2.top();           bal2.pop();           ans[tmp].second = i;           ans[i] = make_pair(ans[tmp].first, 0);         } else if (!bal3.empty()) {           if (vn - v1 == 1) {             cout << -1;             return 0;           }           vn--;           ans[i] = make_pair(vn, 0);           int tmp = bal3.top();           bal3.pop();           ans[tmp].second = i;         } else {           if (vn - v1 == 1) {             cout << -1;             return 0;           }           vn--;           ans[i] = make_pair(vn, 0);         }       } else {         continue;       }     }     for (int i = 0; i < n; i++) {       if (ans[i].second == -1) {         cout << -1 << endl;         return 0;       }     }     set<pair<int, int>> ansset;     for (int i = 0; i < n; i++) {       if (v[i] == 1) {         ansset.insert(make_pair(i + 1, ans[i].first + 1));       }       if (v[i] == 2) {         ansset.insert(make_pair(i + 1, ans[i].first + 1));         ansset.insert(make_pair(ans[i].second + 1, ans[i].first + 1));       }       if (v[i] == 3) {         ansset.insert(make_pair(i + 1, ans[i].first + 1));         ansset.insert(make_pair(ans[i].second + 1, ans[i].first + 1));         ansset.insert(make_pair(ans[i].second + 1, ans[ans[i].second].first + 1));       }     }     cout << ansset.size() << endl;     for (auto it = ansset.begin(); it != ansset.end(); ++it) {       cout << n + 1 - it->second <<     << it->first << endl;     }   }   