#include <bits/stdc++.h>
using namespace std;
int n;
int deg[1 << 17], s[1 << 17];
vector<int> freee;
vector<pair<int, int> > edges;
int main() {
  cin >> n;
  for (int i = 0; i <= (n - 1); ++i) cin >> deg[i] >> s[i];
  for (int i = 0; i <= (n - 1); ++i)
    if (deg[i] == 1) freee.push_back(i);
  int no, no2;
  while ((int(freee.size()))) {
    no = freee.back();
    freee.pop_back();
    if (no == -1) {
      continue;
    }
    no2 = s[no];
    edges.push_back(make_pair(no, no2));
    s[no2] ^= no;
    deg[no2]--;
    if (deg[no2] == 0) {
      for (int i = 0; i <= ((int(freee.size())) - 1); ++i)
        if (freee[i] == no2) {
          freee[i] = -1;
          break;
        }
    }
    if (deg[no2] == 1) {
      freee.push_back(no2);
    }
  }
  cout << (int(edges.size())) << endl;
  for (int i = 0; i <= ((int(edges.size())) - 1); ++i)
    cout << edges[i].first << " " << edges[i].second << endl;
}
