#include <bits/stdc++.h>
using namespace std;
queue<int> q;
vector<pair<int, int> > ed;
int n, a, b, viz[2000100], x, gr[2000100], val[2000100];
int main() {
  cin >> n;
  for (register int i = 0; i < n; ++i) {
    cin >> a >> b;
    gr[i] = a;
    val[i] = b;
  }
  for (register int i = 0; i < n; ++i)
    if (gr[i] == 1) {
      q.push(i);
      viz[i] = 1;
    }
  while (!q.empty()) {
    x = q.front();
    q.pop();
    if (!gr[x]) {
      continue;
    }
    ed.push_back(make_pair(x, val[x]));
    val[val[x]] ^= x;
    gr[val[x]]--;
    if (gr[val[x]] == 1 && !viz[val[x]]) {
      viz[val[x]] = 1;
      q.push(val[x]);
    }
  }
  cout << ed.size() << "\n";
  for (vector<pair<int, int> >::iterator it = ed.begin(); it != ed.end(); it++)
    cout << it->first << " " << it->second << "\n";
  return 0;
}
