#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = int(1 << 16) + 10;
int a[N], d[N];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> a[i];
    if (d[i] == 1) q.push(i);
  }
  set<pair<int, int>> s;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (d[u] != 1) continue;
    if (u == a[u]) continue;
    s.emplace(min(u, a[u]), max(u, a[u]));
    d[a[u]]--;
    if (d[a[u]] == 1) q.push(a[u]);
    a[a[u]] ^= u;
  }
  cout << s.size() << '\n';
  for (auto &[u, v] : s) {
    cout << u << ' ' << v << '\n';
  }
  return 0;
}
