#include <bits/stdc++.h>
using namespace std;
int n;
queue<int> q;
int d[1 << 17];
int s[1 << 17];
set<pair<int, int> > g;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n - 1; i++) cin >> d[i] >> s[i];
  for (int i = 0; i <= n - 1; i++) {
    if (d[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int x = q.front();
    int y = s[x];
    q.pop();
    if (d[x] != 1) continue;
    g.insert(make_pair(x, y));
    d[y]--;
    if (d[y] == 1) q.push(y);
    s[y] ^= x;
  }
  cout << g.size() << endl;
  set<pair<int, int> >::iterator it;
  for (it = g.begin(); it != g.end(); it++)
    cout << (*it).first << " " << (*it).second << endl;
  return 0;
}
