#include <bits/stdc++.h>
using namespace std;
int dg[1 << 16], s[1 << 16];
vector<pair<int, int> > ans;
string XOR(string a, string b) {
  if (a.size() < b.size()) {
    swap(a, b);
  }
  for (int i = 0; i < b.size(); i++) {
    if (a[i] == b[i]) {
      a[i] = '0';
    } else {
      a[i] = '1';
    }
  }
  return a;
}
int tbd(string a) {
  int b = 0, c = 1;
  for (int i = 0; i < a.size(); i++) {
    b += (a[i] - '0') * c;
    c *= 2;
  }
  return b;
}
string tbd(int a) {
  string b = "";
  for (int i = 0; a != 0; i++) {
    b += char((a % 2) + '0');
    a /= 2;
  }
  return b;
}
void anss(int v) {
  dg[v]--;
  dg[s[v]]--;
  pair<int, int> tmp;
  tmp.first = v;
  tmp.second = s[v];
  ans.push_back(tmp);
  s[s[v]] = tbd(XOR(tbd(s[s[v]]), tbd(v)));
  cerr << s[s[v]] << endl;
  if (dg[s[v]] == 1) {
    anss(s[v]);
  }
  return;
}
int main() {
  int n, m = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> dg[i] >> s[i];
    m += dg[i];
  }
  m /= 2;
  for (int i = 0; i < n; i++) {
    if (dg[i] == 1) {
      anss(i);
    }
  }
  cout << m << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
