#include <bits/stdc++.h>
const double EPS = 1e-24;
const long long mod = 1000000007ll;
const double PI = 3.14159265359;
int INF = 2147483645;
template <class T>
T Max2(T a, T b) {
  return a < b ? b : a;
}
template <class T>
T Min2(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T Max3(T a, T b, T c) {
  return Max2(Max2(a, b), c);
}
template <class T>
T Min3(T a, T b, T c) {
  return Min2(Min2(a, b), c);
}
template <class T>
T Max4(T a, T b, T c, T d) {
  return Max2(Max2(a, b), Max2(c, d));
}
template <class T>
T Min4(T a, T b, T c, T d) {
  return Min2(Min2(a, b), Max2(c, d));
}
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
int degree[(1 << 16) + 10];
int s[(1 << 16) + 10];
queue<int> q;
vector<pair<int, int> > V;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> degree[i];
    cin >> s[i];
    if (degree[i] == 1) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    int a = q.front();
    q.pop();
    if (degree[a] == 0) continue;
    degree[a] -= 1;
    int x = s[a];
    V.push_back(make_pair(a, x));
    degree[x] -= 1;
    s[x] = s[x] ^ a;
    if (degree[x] == 1) {
      q.push(x);
    }
  }
  cout << V.size() << endl;
  for (int i = 0; i < V.size(); i++) {
    cout << V[i].first << " " << V[i].second << endl;
  }
  return 0;
}
