#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int main(void) {
  int n;
  cin >> n;
  int deg[n], xtot[n];
  for (int i = 0; i < n; i++) cin >> deg[i] >> xtot[i];
  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 1) q.push(i);
  }
  vector<pair<int, int> > edges;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (deg[v] != 1) continue;
    edges.push_back(make_pair(v, xtot[v]));
    deg[xtot[v]]--;
    xtot[xtot[v]] ^= v;
    if (deg[xtot[v]] == 1) q.push(xtot[v]);
  }
  cout << edges.size() << '\n';
  for (int i = 0; i < edges.size(); i++)
    cout << edges[i].first << ' ' << edges[i].second << '\n';
  return 0;
}
