#include <bits/stdc++.h>
using namespace std;
int Degree[100005], X[100005];
int N, Result;
queue<int> Q;
pair<int, int> Solution[100005];
void Read() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> Degree[i] >> X[i];
}
void Solve() {
  int i;
  for (i = 0; i < N; i++)
    if (Degree[i] == 1) Q.push(i);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    if (Degree[x] == 0) continue;
    int father = X[x];
    Solution[++Result] = make_pair(x, father);
    X[father] ^= x;
    Degree[father]--;
    if (Degree[father] == 1) Q.push(father);
  }
}
int main() {
  Read();
  Solve();
  cout << Result << "\n";
  for (int i = 1; i <= Result; i++)
    cout << Solution[i].first << " " << Solution[i].second << "\n";
  return 0;
}
