#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int d[MAXN], s[MAXN];
vector<pair<int, int> > ans;
set<pair<int, pair<int, int> > > ver;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    ver.insert({d[i], {s[i], i}});
  }
  while (ver.size()) {
    int deg = ver.begin()->first, adj = ver.begin()->second.first,
        v = ver.begin()->second.second;
    ver.erase(ver.begin());
    if (deg == 0) continue;
    ver.erase({d[adj], {s[adj], adj}});
    ans.push_back({v, adj});
    s[adj] ^= v;
    d[adj]--;
    ver.insert({d[adj], {s[adj], adj}});
  }
  cout << ans.size() << endl;
  for (auto u : ans) cout << u.first << ' ' << u.second << endl;
  return 0;
}
