#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, f, b, c = 0;
  cin >> t;
  pair<long long, long long> a[t];
  vector<long long> s;
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < t; i++) {
    cin >> f >> b;
    if (f == 1)
      s.push_back(i);
    else if (f != 0)
      c++;
    a[i] = make_pair(f, b);
  }
  while (c != 0 || s.size() != 0) {
    v.push_back(make_pair(*s.begin(), a[*s.begin()].second));
    a[a[*s.begin()].second].second ^= *s.begin();
    a[a[*s.begin()].second].first--;
    if (a[a[*s.begin()].second].first == 1) {
      c--;
      s.push_back(a[*s.begin()].second);
    } else if (a[a[*s.begin()].second].first == 0) {
      s.erase(find(s.begin(), s.end(), a[*s.begin()].second));
    }
    s.erase(s.begin());
  }
  cout << v.size() << "\n";
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
}
