#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18;
int n, deg[maxn], s[maxn];
queue<int> que;
vector<pair<int, int> > vc;
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(i);
  }
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (deg[u] != 1) continue;
    int v = s[u];
    vc.push_back(pair<int, int>(u, v));
    deg[v]--;
    deg[u]--;
    if (deg[v] == 1) que.push(v);
    s[v] = s[v] ^ u;
    s[u] = s[u] ^ v;
  }
  int ans = vc.size();
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++) {
    pair<int, int> &e = vc[i];
    printf("%d %d\n", e.first, e.second);
  }
}
