#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Pt {
  T x, y;
  void scan() { cin >> x >> y; }
};
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
template <typename T>
inline int sign(const T& a) {
  return a < 0 ? -1 : a > 0;
}
void task();
int main() {
  task();
  return 0;
}
int n;
int deg[65536 + 10];
int sum[65536 + 10];
set<int> ones;
void task() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> deg[i] >> sum[i];
  int m = 0;
  for (int i = 0; i < n; ++i) {
    m += deg[i];
    if (deg[i] == 1) ones.insert(i);
  }
  m /= 2;
  cout << m << "\n";
  for (int i = 0; i < m; ++i) {
    int id = *ones.begin();
    ones.erase(ones.begin());
    ones.erase(sum[id]);
    cout << id << ' ' << sum[id] << "\n";
    --deg[sum[id]];
    sum[sum[id]] ^= id;
    if (deg[sum[id]] == 1) ones.insert(sum[id]);
  }
}
