#include <bits/stdc++.h>
using namespace std;
pair<int, int> ds[100010];
int exor[100010];
int nisi[100010];
vector<pair<int, int> > ans;
queue<int> heyo;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> ds[i].first >> ds[i].second;
    if (ds[i].first == 1) {
      heyo.push(i);
    }
  }
  while (!heyo.empty()) {
    int ele1 = heyo.front();
    heyo.pop();
    int deg1 = ds[ele1].first;
    int sum1 = ds[ele1].second;
    if (nisi[ele1] == deg1) {
      continue;
    }
    int ele2 = exor[ele1] ^ sum1;
    exor[ele2] ^= ele1;
    nisi[ele1]++;
    nisi[ele2]++;
    int deg2 = ds[ele2].first;
    if (nisi[ele2] == deg2 - 1) {
      heyo.push(ele2);
    }
    ans.push_back(make_pair(ele1, ele2));
  }
  cout << ans.size() << "\n";
  for (int i = 0; i <= (int)ans.size() - 1; i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
