#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int degree[1 << 16], s[1 << 16];
  for (int i = 0; i < n; i++) cin >> degree[i] >> s[i];
  queue<int> qq;
  for (int i = 0; i < n; i++)
    if (degree[i] == 1) qq.push(i);
  vector<pair<int, int> > ans;
  while (qq.size()) {
    int a = qq.front();
    qq.pop();
    if (degree[a] == 0) continue;
    int b = s[a];
    ans.push_back(make_pair(a, b));
    degree[a]--;
    degree[b]--;
    s[b] ^= a;
    if (degree[b] == 1) qq.push(b);
  }
  n = ans.size();
  cout << n << endl;
  for (int i = 0; i < n; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
