#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, deg[N], s[N];
vector<int> que;
vector<pair<int, int> > res;
void add_edge(int a, int b) {
  deg[a]--;
  deg[b]--;
  res.push_back({a, b});
  s[a] ^= b;
  s[b] ^= a;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &deg[i], &s[i]);
    if (deg[i] == 1) {
      que.push_back(i);
    }
  }
  for (int i = 0; i < que.size(); i++) {
    int v = que[i];
    if (deg[v] == 1) {
      int nei = s[v];
      add_edge(v, s[v]);
      if (deg[nei] == 1) {
        que.push_back(nei);
      }
    }
  }
  printf("%d\n", res.size());
  for (auto p : res) {
    printf("%d %d\n", p.first, p.second);
  }
  return 0;
}
