#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200015;
const int MOD = 1000000007;
vector<pair<int, int> > edges;
struct node {
  int deg, ind, val;
  node(int x, int y, int z) : deg(x), ind(y), val(z) {}
};
vector<node> G;
queue<int> Q;
bool visit[MAXN];
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) {
    scanf("%d", &x), scanf("%d", &y);
    G.push_back(node(x, i, y));
  }
  memset(visit, 0, sizeof(visit));
  for (int i = 0; i <= n - 1; i++) {
    if (G[i].deg == 1) {
      int u = G[i].ind;
      int v = G[i].val;
      G[v].deg--;
      G[v].val ^= u;
      visit[u] = true;
      if (G[v].deg == 1 and !visit[v]) Q.push(v);
      assert(u != v);
      edges.push_back(make_pair(u, v));
    }
  }
  while (!Q.empty()) {
    int u = Q.front();
    int v = G[u].val;
    Q.pop();
    if (visit[u] or G[u].deg != 1) continue;
    visit[u] = true;
    G[v].val ^= G[u].ind;
    G[v].deg--;
    if (G[v].deg == 1 and !visit[v]) Q.push(v);
    assert(u != v);
    edges.push_back(make_pair(u, v));
  }
  printf("%d\n", ((int)(edges.size())));
  for (int i = 0; i <= ((int)(edges.size())) - 1; i++) {
    printf("%d %d\n", edges[i].first, edges[i].second);
  }
  return 0;
}
