#include <bits/stdc++.h>
using namespace std;
long long n, m, i, ans;
long long x[100005], y[100005];
long long sz[100005], xr[100005];
queue<long long> q;
vector<pair<long long, long long> > edge;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    if (x[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    long long idx = q.front();
    q.pop();
    if (sz[idx] == x[idx]) continue;
    if (sz[idx] < x[idx] - 1) continue;
    if (sz[idx] == x[idx] - 1) {
      sz[idx]++;
      long long v = y[idx] ^ xr[idx];
      sz[v]++;
      xr[v] ^= idx;
      edge.push_back(make_pair(idx, v));
      q.push(v);
    }
  }
  cout << edge.size() << "\n";
  for (i = 0; i < edge.size(); i++)
    cout << edge[i].first << " " << edge[i].second << "\n";
  return 0;
}
