#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  pair<int, int> pi[n];
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    cin >> pi[i].first >> pi[i].second;
    if (pi[i].first == 1) q.push(i);
  }
  int count = 0;
  std::vector<int> v[n + 1];
  while (!q.empty()) {
    int t = q.front();
    int k;
    if (pi[t].first > 0) {
      count++;
      v[t].push_back(pi[t].second);
      k = pi[t].second;
      pi[k].first--;
      pi[t].first--;
      pi[t].second = pi[t].second ^ k;
      pi[k].second = pi[k].second ^ t;
    }
    q.pop();
    if (pi[k].first == 1) q.push(k);
  }
  cout << count << "\n";
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      cout << v[i][j] << " " << i << "\n";
    }
  }
  return 0;
}
