#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int aristas = 0;
  vector<pair<int, int> > nodos;
  queue<pair<int, int> > procesar;
  for (int i = 0; i < n; i++) {
    int degree, XOR;
    cin >> degree >> XOR;
    aristas += degree;
    nodos.push_back(make_pair(degree, XOR));
    if (degree == 1) procesar.push(make_pair(i, XOR));
  }
  vector<pair<int, int> > edges;
  while (!procesar.empty()) {
    int nodo = procesar.front().first;
    int XOR = procesar.front().second;
    procesar.pop();
    if (nodos[nodo].first != 0) edges.push_back(make_pair(nodo, XOR));
    nodos[XOR].first--;
    nodos[XOR].second ^= nodo;
    if (nodos[XOR].first == 1) procesar.push(make_pair(XOR, nodos[XOR].second));
  }
  cout << aristas / 2 << "\n";
  for (int i = 0; i < edges.size(); i++)
    cout << edges[i].first << " " << edges[i].second << "\n";
  return 0;
}
