#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(long long x) {
  stringstream second;
  second << x;
  return second.str();
}
long long stl(string x) {
  stringstream second(x);
  long long temp;
  second >> temp;
  return temp;
}
string cts(char x) {
  string second(1, x);
  return second;
}
const int MOD = 1e9 + 7;
const int MAXN = 305;
template <typename T>
void maxself(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void minself(T& a, T b) {
  a = min(a, b);
}
int degree[65540];
int xo[65540];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  queue<int> q;
  for (long long i = (0); i <= (long long)(n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 0) continue;
    degree[i] = a, xo[i] = b;
    if (a == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > ans;
  while (q.size()) {
    int c = q.front();
    q.pop();
    if (degree[c] == 0) continue;
    --degree[c];
    int to = xo[c];
    ans.push_back(pair<int, int>(c, to));
    xo[to] ^= c;
    --degree[to];
    if (degree[to] == 1) q.push(to);
  }
  cout << ans.size() << '\n';
  for (auto i : ans) {
    cout << i.first << ' ' << i.second << '\n';
  }
}
