#include <bits/stdc++.h>
using namespace std;
map<long long, pair<long long, long long>> m1;
int main() {
  long long n, i, j;
  cin >> n;
  queue<long long> q;
  for (i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    m1[i] = {x, y};
    if (x == 1) {
      q.push(i);
    }
  }
  vector<pair<long long, long long>> ans;
  while (q.size() > 0) {
    long long pos;
    pos = q.front();
    q.pop();
    if (m1[pos].first == 0) continue;
    m1[pos].first--;
    ans.push_back({pos, m1[pos].second});
    long long tt;
    tt = m1[pos].second;
    m1[tt].first--;
    (m1[tt].second ^= pos);
    if (m1[tt].first == 1) {
      q.push(tt);
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << '\n';
  return 0;
}
