#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a, b, ans;
int n;
void solve(int q) {
  if (a[q].first == 1) {
    a[q].first--;
    ans.push_back(make_pair(q, a[q].second));
    a[a[q].second].second = a[a[q].second].second ^ q;
    a[a[q].second].first--;
    solve(a[q].second);
  }
}
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  b = a;
  for (int i = 0; i < n; i++)
    if (a[i].first == 1) {
      ans.push_back(make_pair(i, a[i].second));
      a[i].first--;
      a[a[i].second].second = a[a[i].second].second ^ i;
      a[a[i].second].first--;
      solve(a[i].second);
    }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << ' ' << ans[i].second << endl;
}
