#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int INF = 0x3f3f3f3f;
vector<pair<int, int> > e;
int d[maxn], s[maxn];
int main() {
  int n, u, v;
  cin >> n;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (d[u] == 1) {
      int v = s[u];
      e.push_back(make_pair(u, v));
      d[v]--;
      s[v] ^= u;
      if (d[v] == 1) q.push(v);
    }
  }
  cout << e.size() << endl;
  for (auto x : e) cout << x.first << " " << x.second << endl;
}
