#include <bits/stdc++.h>
using namespace std;
const long long int N = (1 << 17);
long long int degree[N], xorsum[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  queue<long long int> q;
  long long int cnt = n;
  for (long long int i = 0; i < n; i++) {
    cin >> degree[i] >> xorsum[i];
    if (degree[i] == 1) q.push(i);
  }
  vector<pair<long long int, long long int> > ans;
  while (!q.empty()) {
    long long int curr = q.front();
    q.pop();
    if (degree[curr] == 0) continue;
    long long int to = xorsum[curr];
    ans.push_back(make_pair(curr, to));
    xorsum[to] ^= curr;
    degree[to]--;
    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;
}
