#include <bits/stdc++.h>
using namespace std;
const int MAX = 66000;
int d[MAX], s[MAX], marque[MAX], n, comp;
vector<int> to_do, son[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) {
      marque[i] = 1;
      to_do.push_back(i);
    }
  }
  while (!to_do.empty()) {
    int x = to_do.back();
    to_do.pop_back();
    if (d[x] == (int)son[x].size()) continue;
    comp++;
    int y = s[x];
    for (int i : son[x]) y ^= i;
    son[y].push_back(x);
    if (d[y] - 1 == (int)son[y].size()) {
      marque[y] = 1;
      to_do.push_back(y);
    }
  }
  cout << comp << endl;
  for (int i = 0; i < n; i++)
    for (int j : son[i]) cout << i << " " << j << endl;
  return 0;
}
