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