#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int deg[maxn], xx[maxn];
queue<int> Q;
bool mark[maxn];
vector<pair<int, int> > v;
void add(int fi, int se) { v.push_back(make_pair(fi, se)); }
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xx[i];
    if (deg[i] == 1) {
      Q.push(i);
      mark[i] = true;
    }
  }
  while (Q.size()) {
    int x = Q.front();
    Q.pop();
    if (deg[x] == 0) continue;
    add(x, xx[x]);
    deg[xx[x]]--;
    xx[xx[x]] ^= x;
    deg[x]--;
    if (deg[xx[x]] == 1 and !mark[xx[x]]) {
      Q.push(xx[x]);
      mark[xx[x]] = true;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
}
