#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> indeg(n);
  queue<int> deg1;
  vector<int> xorV(n);
  for (int i = 0; i < n; i++) {
    cin >> indeg[i] >> xorV[i];
    if (indeg[i] == 1) deg1.push(i);
  }
  set<pair<int, int> > edges;
  while (deg1.size() > 0) {
    int v = deg1.front();
    deg1.pop();
    int u = xorV[v];
    if (--indeg[u] == 1) deg1.push(u);
    if (indeg[u] > 0) xorV[u] ^= v;
    if (v > u) swap(u, v);
    edges.insert({u, v});
  }
  cout << edges.size() << endl;
  for (auto &edg : edges) {
    cout << edg.first << ' ' << edg.second << endl;
  }
  return 0;
}
