#include <bits/stdc++.h>
using namespace std;
inline void io() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void PV(vector<long long> v) {
  for (long long i = 0; i < (long long)v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void PA(long long v[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cout << v[i] << " ";
  cout << "\n";
}
void IA(long long a[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cin >> a[i];
}
const long long N = (1 << 16) + 7, N9 = 1e9 + 7;
long long n, deg[N], xs[N];
vector<vector<long long> > v(N);
void solve() {
  cin >> n;
  vector<long long> v1;
  long long ct = n;
  for (long long i = 0; i < n; i++) {
    cin >> deg[i] >> xs[i];
    if (deg[i] == 1) {
      v1.push_back(i);
    }
    if (deg[i] == 0) {
      ct--;
    }
  }
  while (ct) {
    vector<long long> pv;
    for (long long i = 0; i < (long long)v1.size(); i++) {
      if (deg[v1[i]] == 0) continue;
      long long ii = xs[v1[i]];
      deg[ii]--;
      xs[ii] ^= v1[i];
      if (deg[ii] == 1) {
        pv.push_back(ii);
      }
      if (deg[ii] == 0) {
        ct--;
      }
      v[ii].push_back(v1[i]);
      ct--;
    }
    v1.clear();
    for (long long i = 0; i < (long long)pv.size(); i++) {
      if (deg[pv[i]] == 0) continue;
      v1.push_back(pv[i]);
    }
  }
  long long sm = 0;
  for (long long i = 0; i < n; i++) {
    sm += (long long)v[i].size();
  }
  cout << sm << "\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < (long long)v[i].size(); j++) {
      cout << i << " " << v[i][j] << "\n";
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t1 = 1;
  cout << fixed << setprecision(10);
  while (t1--) {
    solve();
  }
}
