#include <bits/stdc++.h>
using namespace std;
vector<int> E[65600];
vector<pair<int, int> > V;
int main() {
  int n;
  scanf("%d", &n);
  queue<int> Q;
  int degree[65600 + 10], Xsum[65600 + 10];
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    degree[i] = a;
    Xsum[i] = b;
    if (degree[i] == 1) Q.push(i);
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (degree[u] == 0) continue;
    int othernode = Xsum[u];
    V.push_back(make_pair(u, othernode));
    degree[othernode]--;
    degree[u]--;
    Xsum[othernode] = Xsum[othernode] ^ u;
    if (degree[othernode] == 1) Q.push(othernode);
  }
  printf("%d\n", V.size());
  for (int i = 0; i < V.size(); i++) printf("%d %d\n", V[i].first, V[i].second);
  return 0;
}
