#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  queue<pair<int, int>> q;
  map<int, pair<int, int>> m;
  for (int i = 0; i < n; i++) {
    int d, s;
    cin >> d >> s;
    if (d == 1) {
      q.push(make_pair(i, s));
    } else {
      m[i] = make_pair(d, s);
    }
  }
  set<pair<int, int>> v;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    pair<int, int> p1 = make_pair(p.second, p.first);
    if (v.find(p1) == v.end() && v.find(p) == v.end()) {
      v.insert(p);
    }
    if (m.count(p.second) > 0) {
      m[p.second].first -= 1;
      m[p.second].second ^= p.first;
      if (m[p.second].first == 1) {
        q.push(make_pair(p.second, m[p.second].second));
      }
    }
  }
  cout << v.size() << endl;
  for (set<pair<int, int>>::iterator i = v.begin(); i != v.end(); i++) {
    pair<int, int> p = *i;
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}
