#include <bits/stdc++.h>
using namespace std;
int degree[100005];
int s[100005];
vector<pair<int, int> > G;
set<pair<int, int> > Q;
int main() {
  int n;
  int a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    degree[i] = a;
    s[i] = b;
    Q.insert(make_pair(degree[i], i));
  }
  pair<int, int> cur;
  set<pair<int, int> >::iterator it;
  int next, i;
  while (Q.size() != 1) {
    it = Q.begin();
    i = it->second;
    Q.erase(it);
    if (degree[i] == 0) continue;
    next = s[i];
    G.push_back(make_pair(i, next));
    Q.erase(make_pair(degree[next], next));
    degree[next]--;
    s[next] ^= i;
    Q.insert(make_pair(degree[next], next));
  }
  cout << G.size() << endl;
  for (int i = 0; i < G.size(); i++) {
    cout << G[i].first << " " << G[i].second << endl;
  }
}
