#include <bits/stdc++.h>
using namespace std;
struct compare {
  bool operator()(const pair<int, int> &p1, const pair<int, int> &p2) {
    return p1.first > p2.first;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> D(n), S(n);
  priority_queue<pair<int, int>, vector<pair<int, int> >, compare> pq;
  for (int i = 0; i < n; ++i) {
    cin >> D[i] >> S[i];
    pq.push(make_pair(D[i], i));
  }
  set<pair<int, int> > Edge;
  while (!pq.empty()) {
    int deg = pq.top().first, u = pq.top().second;
    if (deg > 1) {
      break;
    }
    pq.pop();
    int adj = S[u];
    if (D[u] != 1) {
      continue;
    }
    if (Edge.find(make_pair(u, S[u])) == Edge.end() and
        Edge.find(make_pair(S[u], u)) == Edge.end())
      Edge.insert(make_pair(u, S[u]));
    S[adj] ^= u;
    D[adj]--;
    pq.push(make_pair(D[adj], adj));
  }
  cout << (int)Edge.size() << "\n";
  for (set<pair<int, int> >::iterator itr = Edge.begin(); itr != Edge.end();
       ++itr) {
    cout << (*itr).first << " " << (*itr).second << "\n";
  }
  return 0;
}
