#include <bits/stdc++.h>
using namespace std;
struct vis {
  int d, x;
};
vis a[100000];
int v[100000];
set<pair<int, int> > s;
pair<int, int> findmin() {
  pair<int, int> p;
  while (p.first == 0 && !s.empty()) {
    set<pair<int, int> >::iterator it = s.begin();
    p = *it;
    s.erase(p);
  }
  return p;
}
int main() {
  int n, ans = 0;
  cin >> n;
  fill(v, v + n, -1);
  for (int i = 0; i < n; i++) {
    cin >> a[i].d >> a[i].x;
    s.insert(make_pair(a[i].d, i));
  }
  while (1) {
    pair<int, int> p = findmin();
    if (p.first == 0) break;
    v[p.second] = a[p.second].x;
    int k = a[p.second].x;
    a[k].x ^= p.second;
    a[k].d--;
    s.erase(make_pair(a[k].d + 1, k));
    s.insert(make_pair(a[k].d, k));
  }
  for (int i = 0; i < n; i++)
    if (v[i] != -1) ans++;
  cout << ans << endl;
  for (int i = 0; i < n; i++)
    if (v[i] != -1) cout << i << " " << v[i] << endl;
  return 0;
}
