#include <bits/stdc++.h>
using namespace std;
const long long int M = 1e9 + 7;
const long long int N = 2e5 + 5;
const long long int inf = 2e18;
long long int mod(long long int x) { return (x % M); }
long long int mod_minus(long long int a, long long int b) {
  long long int ans = (mod(a) - mod(b));
  if (ans < 0) ans = mod(ans + M);
  return ans;
}
long long int mod_mul(long long int a, long long int b) {
  return mod(mod(a) * mod(b));
}
long long int mod_add(long long int a, long long int b) { return mod(a + b); }
long long int power(long long int a, long long int n) {
  if (n == 0)
    return 1;
  else if (n == 1)
    return a;
  long long int R = power(a, n / 2) % M;
  if (n % 2 == 0) {
    return mod(mod_mul(R, R));
  } else {
    return mod(mod_mul(mod_mul(R, a), mod(R)));
  }
}
long long int mod_inv(long long int n) { return power(n, M - 2); }
long long int mod_div(long long int a, long long int b) {
  long long int ans = mod(a);
  long long int b1 = power(b, M - 2);
  ans = mod(mod_mul(ans, b1));
  return ans;
}
long long int fact_mod(long long int n) {
  vector<long long int> fact(n + 1);
  fact[0] = 1;
  for (long long int i = 1; i < n + 1; i++) {
    fact[i] = mod_mul(fact[i - 1], i);
  }
  return fact[n];
}
long long int nCr_mod(long long int n, long long int r) {
  if (r == 0 || n == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % M;
  return (fac[n] * mod_inv(fac[r]) % M * mod_inv(fac[n - r]) % M) % M;
}
int main() {
  long long int n;
  cin >> n;
  long long int i;
  queue<pair<long long int, long long int>> q;
  vector<pair<long long int, long long int>> v(n);
  for (i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    v[i] = {x, y};
    if (x == 1) q.push({i, y});
  }
  vector<pair<long long int, long long int>> ans;
  while (q.empty() == false) {
    pair<long long int, long long int> temp = q.front();
    q.pop();
    ans.push_back({temp});
    long long int x = temp.second;
    v[x].first--;
    v[x].second = temp.first ^ v[x].second;
    if (v[x].first == 1) q.push({x, v[x].second});
  }
  set<pair<long long int, long long int>> s;
  for (auto x : ans) {
    if (!s.count({x.first, x.second}) && !s.count({x.second, x.first}))
      s.insert({x.first, x.second});
  }
  cout << s.size() << endl;
  for (auto x : s) cout << x.first << ' ' << x.second << endl;
}
