#include <bits/stdc++.h>
using namespace std;
int deg[1 << 18], sum[1 << 18];
int main() {
  vector<pair<int, int> > v;
  queue<pair<int, int> > q;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int d, x;
    cin >> d >> x;
    deg[i] = d;
    sum[i] = x;
    if (d == 1) {
      q.push({i, x});
    }
  }
  while (!q.empty()) {
    pair<int, int> top = q.front();
    q.pop();
    int from = top.first, to = top.second;
    if (deg[from] == 0 || deg[to] == 0) {
      continue;
    }
    int newx = sum[to] ^ from;
    sum[to] = newx;
    deg[to]--;
    deg[from]--;
    if (deg[to] == 1) {
      q.push({to, newx});
    }
    v.push_back({from, to});
  }
  cout << v.size() << endl;
  for (auto it : v) {
    cout << it.first << " " << it.second << endl;
  }
  return 0;
}
