#include <bits/stdc++.h>
using namespace std;
const long long nax = 1e5 + 5;
vector<long long> adj[nax];
const long long mod = 1e9 + 7;
const long long inf = 1e18 + 7;
long long deg[nax];
long long x[nax];
vector<pair<long long, long long>> ed;
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> deg[i] >> x[i];
  }
  queue<pair<long long, long long>> q;
  for (long long i = 0; i < n; i++) {
    if (deg[i] == 1) {
      q.push({i, x[i]});
    }
  }
  while (!q.empty()) {
    long long cur = q.front().first;
    long long xr = q.front().second;
    q.pop();
    if (deg[cur] == 0) continue;
    ed.push_back({cur, xr});
    deg[xr]--;
    x[xr] ^= cur;
    if (deg[xr] == 1) {
      q.push({xr, x[xr]});
    }
  }
  cout << ed.size() << endl;
  for (auto u : ed) {
    cout << u.first << " " << u.second << endl;
  }
  return 0;
}
