#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vertices;
vector<pair<int, int> > edges;
int main() {
  int v;
  cin >> v;
  int a, b;
  queue<int> q;
  for (int i = 0; i < v; i++) {
    cin >> a >> b;
    vertices.push_back(make_pair(a, b));
    if (a == 1) {
      q.push(i);
    }
  }
  int size = v;
  while (q.empty() == false) {
    int i = q.front();
    q.pop();
    if (vertices[i].first == 1) {
      int ver = vertices[i].second;
      edges.push_back(make_pair(i, ver));
      vertices[ver].first--;
      vertices[ver].second ^= i;
      if (vertices[ver].first == 1) {
        q.push(ver);
      }
    }
  }
  cout << edges.size() << endl;
  for (int i = 0; i < edges.size(); i++) {
    cout << edges[i].first << " " << edges[i].second << endl;
  }
  return 0;
}
