#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int x[100009], e[100009];
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k, n;
  while (cin >> n) {
    queue<int> Q;
    for (i = 0; i < (n); i++) {
      cin >> e[i] >> x[i];
      if (e[i] == 1) Q.push(i);
    }
    set<pair<int, int> > S;
    while (!Q.empty()) {
      int tp = Q.front();
      Q.pop();
      if (e[tp] == 1) {
        x[x[tp]] ^= tp;
        e[x[tp]]--;
        S.insert(make_pair(min(tp, x[tp]), max(tp, x[tp])));
        if (e[x[tp]] == 1) {
          Q.push(x[tp]);
        }
      }
      x[tp] ^= tp;
      e[tp]--;
    }
    cout << (int)S.size() << endl;
    set<pair<int, int> >::iterator it = S.begin();
    for (; it != S.end(); it++) {
      cout << it->first << " " << it->second << endl;
    }
  }
}
