#include <bits/stdc++.h>   using namespace std;   int d[66000], s[66000];   int que[66000];   bool f[66000];   int n, m;   vector<pair<int, int> > res;   int biton(int x, int k) { return (x | (1 << k)); }   int Minus(int x, int y) {     int z = 0;     for (int i = 0; i < 17; i++) {       int u = ((x >> i) & 1);       int v = ((y >> i) & 1);       if (u != v) z = biton(z, i);     }     return z;   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) cin >> d[i] >> s[i];     for (int i = 0; i < n; i++)       if (d[i] == 1) {         f[i] = true;         m++;         que[m] = i;       }     while (m > 0) {       int u = que[m];       if (d[u] == 0) {         m--;         continue;       }       int v = s[u];       res.push_back(make_pair(u, v));       s[v] = Minus(s[v], u);       d[v]--;       m--;       if (d[v] == 1 && f[v] == false) {         f[v] = true;         m++;         que[m] = v;       }     }     cout << res.size() <<   n ;     for (int i = 0; i < res.size(); i++)       cout << res[i].first <<     << res[i].second <<   n ;     return 0;   }   