#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    pair<int, int> p[n];
    for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
    vector<int> one;
    for (int i = 0; i < n; i++)
      if (p[i].first == 1) one.push_back(i);
    vector<pair<int, int> > edges;
    vector<int> newone;
    while (one.size() > 0) {
      for (int i = 0; i < one.size(); i++) {
        int curr = one[i];
        if (p[curr].first != 1) continue;
        edges.push_back({p[curr].second, curr});
        p[p[curr].second].first--;
        if (p[p[curr].second].first == 1) newone.push_back(p[curr].second);
        p[curr].first--;
        p[p[curr].second].second ^= curr;
      }
      one = newone;
      newone.clear();
    }
    cout << edges.size() << endl;
    for (int i = 0; i < edges.size(); i++)
      cout << edges[i].first << " " << edges[i].second << endl;
  }
  return 0;
}
