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