#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<set<int> > d(n + 1);
  for (int i = 0; i < n; i++) d[i].clear();
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; i++) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    v[i] = make_pair(temp1, temp2);
    d[temp1].insert(i);
  }
  vector<pair<int, int> > ans;
  set<int>::iterator it = d[1].begin();
  while (1) {
    if (it == d[1].end()) break;
    int vert = *it;
    int deg = v[v[vert].second].first;
    d[1].erase(it);
    d[deg].erase(v[vert].second);
    d[deg - 1].insert(v[vert].second);
    v[v[vert].second].second ^= vert;
    v[v[vert].second].first--;
    assert(v[v[vert].second].first >= 0);
    ans.push_back(make_pair(v[vert].second, vert));
    it = d[1].begin();
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
