#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    Q;
pair<int, int> R[MAXN];
int N, deg[MAXN], A[MAXN];
bool visited[MAXN];
void nhap() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d%d", &deg[i], &A[i]);
}
void tinh() {
  memset(visited, 0, sizeof(visited));
  int res = 0;
  for (int i = 0; i < N; i++) Q.push(make_pair(deg[i], i));
  while (!Q.empty()) {
    pair<int, int> t = Q.top();
    Q.pop();
    if (visited[t.second]) continue;
    visited[t.second] = 1;
    if (t.first == 0) continue;
    int u = A[t.second];
    R[res++] = make_pair(t.second, u);
    A[u] = A[u] ^ t.second;
    deg[u]--;
    Q.push(make_pair(deg[u], u));
  }
  printf("%d\n", res);
  for (int i = 0; i < res; i++) printf("%d %d\n", R[i].first, R[i].second);
}
int main() {
  nhap();
  tinh();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
