#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
queue<int> que;
map<int, int> ans;
int du[70000], sum[70000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> du[i] >> sum[i];
    if (du[i] == 1) que.push(i);
  }
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (du[u] != 1) continue;
    ans[u] = sum[u];
    du[u]--;
    du[sum[u]]--;
    sum[sum[u]] ^= u;
    if (du[sum[u]] == 1) que.push(sum[u]);
  }
  auto len = ans.size();
  cout << len << endl;
  for (auto iter = ans.begin(); iter != ans.end(); iter++)
    cout << iter->first << " " << iter->second << endl;
  return 0;
}
