#include <bits/stdc++.h>
using namespace std;
struct node {
  int degree;
  int xorsum;
};
struct Edge {
  int src, des;
};
struct node virtex[100000];
vector<struct Edge> edge;
vector<struct Edge>::iterator it;
queue<int> que;
int main() {
  struct Edge temp;
  int n, d, s, i, src, des;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> virtex[i].degree >> virtex[i].xorsum;
  }
  for (i = 0; i < n; i++) {
    if (virtex[i].degree == 1) {
      que.push(i);
    }
  }
  while (!que.empty()) {
    src = que.front();
    que.pop();
    if (virtex[src].degree == 1) {
      des = virtex[src].xorsum;
      temp.src = src;
      temp.des = des;
      edge.push_back(temp);
      virtex[des].degree--;
      virtex[des].xorsum ^= src;
      if (virtex[des].degree == 1) {
        que.push(des);
      }
    }
  }
  cout << edge.size() << endl;
  it = edge.begin();
  while (it != edge.end()) {
    cout << it->src << " " << it->des << endl;
    it++;
  }
  return 0;
}
