#include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
  ios_base::sync_with_stdio(false);
  smain();
  return 0;
}
struct sNode {
  int v;
  int sum;
  int num;
  sNode() {}
  sNode(int _v, int _sum, int _num) {
    v = _v;
    num = _num;
    sum = _sum;
  }
};
bool operator<(const sNode& a, const sNode& b) {
  if (a.num < b.num) return true;
  if (a.num > b.num) return false;
  if (a.sum < b.sum) return true;
  if (a.sum > b.sum) return false;
  if (a.v < b.v) return true;
  return false;
}
void smain() {
  int n;
  cin >> n;
  set<sNode> nodes;
  map<int, pair<int, int> > nd;
  int num, sum, n2, s2, v1, v2;
  for (int i = 0; i < n; i++) {
    cin >> num >> sum;
    nodes.insert(sNode(i, sum, num));
    nd[i] = make_pair(sum, num);
  }
  vector<pair<int, int> > gr;
  while (!nodes.empty()) {
    v1 = nodes.begin()->v;
    num = nodes.begin()->num;
    sum = nodes.begin()->sum;
    nodes.erase(nodes.begin());
    if (num == 0) continue;
    v2 = v1;
    v1 = sum;
    gr.push_back(make_pair(v1, v2));
    sum = nd[v1].first;
    num = nd[v1].second;
    nodes.erase(nodes.find(sNode(v1, sum, num)));
    sum = sum ^ v2;
    num = num - 1;
    nodes.insert(sNode(v1, sum, num));
    nd[v1] = make_pair(sum, num);
  }
  cout << gr.size() << '\n';
  for (int i = 0; i < gr.size(); i++) {
    cout << gr[i].first << ' ' << gr[i].second << '\n';
  }
}
