#include <bits/stdc++.h>
using namespace std;
void RI(int& x) {
  x = 0;
  char c = getchar();
  while (!(c >= '0' && c <= '9' || c == '-')) c = getchar();
  bool flag = 1;
  if (c == '-') {
    flag = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (!flag) x = -x;
}
void RII(int& x, int& y) { RI(x), RI(y); }
void RIII(int& x, int& y, int& z) { RI(x), RI(y), RI(z); }
void RC(char& c) {
  c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
}
char RC() {
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
const long long mod = 1e9 + 7;
const long long LINF = 1e18;
const int INF = 1e9;
const double EPS = 1e-8;
int a[1000005], d[1000005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> d[i] >> a[i];
  }
  queue<int> q;
  for (int i = 0; i <= n - 1; i++) {
    if (d[i] == 1) {
      q.push(i);
    }
  }
  vector<pair<int, int> > ans;
  while ((int)q.size()) {
    int u = q.front();
    q.pop();
    if (d[u] != 1) continue;
    ans.push_back(make_pair(u, a[u]));
    a[a[u]] ^= u;
    d[a[u]]--;
    if (d[a[u]] == 1) {
      q.push(a[u]);
    }
  }
  cout << (int)ans.size() << endl;
  for (int i = 0; i <= (int)ans.size() - 1; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
