func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1E5 + 10;   int n, tot;   int a[N], vis[N], twom[N], threem[N];   vector<int> x, y;   stack<int> one, two, three;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = n; i >= 1; --i) {       if (a[i] == 1) {         one.push(i);       } else if (a[i] == 2) {         if (!one.size()) {           cout << -1 << endl;           return 0;         } else {           twom[i] = one.top();           one.pop();         }         two.push(i);       } else if (a[i] == 3) {         if (three.size()) {           threem[i] = three.top();           three.pop();         } else if (two.size()) {           threem[i] = two.top();         } else if (one.size()) {           threem[i] = one.top();           one.pop();         } else {           cout << -1 << endl;           return 0;         }         three.push(i);       }     }     int currow = 1;     for (int i = 1; i <= n; ++i) {       if (a[i] == 0 || vis[i] == 1) continue;       int curcol = i;       while (curcol) {         vis[curcol] = 1;         if (a[curcol] == 1) {           x.push_back(currow);           y.push_back(curcol);           curcol = 0;           ++currow;         } else if (a[curcol] == 2) {           x.push_back(currow);           y.push_back(curcol);           curcol = twom[curcol];         } else if (a[curcol] == 3) {           x.push_back(currow);           y.push_back(curcol);           curcol = threem[curcol];           x.push_back(currow);           y.push_back(curcol);           ++currow;         }       }     }     cout << x.size() << endl;     for (int i = 0; i <= (int)x.size() - 1; ++i) printf( %d %d n , x[i], y[i]);   }   