#include <bits/stdc++.h>
using namespace std;
long degree[70000];
long xorSum[70000];
long vertexNum;
void printEdge(long v1, long v2) {
  cout << v1 << " " << v2 << endl;
  xorSum[v1] = xorSum[v1] ^ v2;
  xorSum[v2] = xorSum[v2] ^ v1;
  degree[v1]--;
  degree[v2]--;
  if (degree[v1] == 1) printEdge(v1, xorSum[v1]);
  if (degree[v2] == 1) printEdge(v2, xorSum[v2]);
}
int main(void) {
  cin >> vertexNum;
  long total = 0;
  for (long i = 0; i < vertexNum; i++) {
    cin >> degree[i] >> xorSum[i];
    total += degree[i];
  }
  total /= 2;
  cout << total << endl;
  for (long i = 0; i < vertexNum; i++) {
    if (degree[i] == 1) printEdge(i, xorSum[i]);
  }
  cin >> vertexNum;
  return 0;
}
