#include <bits/stdc++.h>
using namespace std;
vector<pair<long, long>> t;
vector<pair<long, long>> ans;
queue<long> q;
int main() {
  long n;
  cin >> n;
  long x, y;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    t.push_back(make_pair(x, y));
    if (x == 1) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    long cur = q.front();
    q.pop();
    if (t[cur].first > 0) {
      long parent = t[cur].second;
      ans.push_back(make_pair(cur, parent));
      t[parent].second ^= cur;
      t[parent].first--;
      if (t[parent].first == 1) {
        q.push(parent);
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto i : ans) {
    cout << i.first << ' ' << i.second << '\n';
  }
}
