#include <bits/stdc++.h>
using namespace std;
long long int degree[100010], sv[100010];
int main() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > ans;
  queue<long long int> q;
  for (long long int i = 0; i < n; i++) {
    cin >> degree[i] >> sv[i];
    if (degree[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    long long int x = q.front();
    q.pop();
    if (degree[x] == 0) continue;
    degree[x]--;
    long long int to = sv[x];
    sv[x] = 0;
    degree[to]--;
    sv[to] ^= x;
    ans.push_back(make_pair(to, x));
    if (degree[to] == 1) q.push(to);
  }
  cout << ans.size() << endl;
  for (long long int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
