#include <bits/stdc++.h>
using namespace std;
void splitstr(const string &s, vector<string> &v) {
  istringstream in(s);
  copy(istream_iterator<string>(in), istream_iterator<string>(),
       back_inserter(v));
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n = 0, a = 0, no[100004], x[100005], t = 0, k = 0, m = 0, i = 0, j = 0,
      ans = 0, b = 0, c = 0, d = 0, y = 0, f = 0, l = 0, r = 0;
  string str, s;
  vector<pair<int, int> > v;
  cin >> n;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    cin >> no[i] >> x[i];
    v.push_back(make_pair(no[i], x[i]));
    ans += no[i];
  }
  cout << ans / 2 << '\n';
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    if (v[i].first == 1) {
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int tem = q.front();
        q.pop();
        v[tem].first -= 1;
        int u = v[tem].second;
        cout << tem << " " << u << '\n';
        v[u].first -= 1;
        v[u].second ^= tem;
        if (v[u].first == 1) q.push(u);
      }
    }
  }
  return 0;
}
