#include <bits/stdc++.h>
using namespace std;
void getre() {
  int x = 0;
  printf("%d\n", 1 / x);
}
void gettle() {
  int res = 1;
  while (1) res <<= 1;
  printf("%d\n", res);
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename N, typename PN>
inline N flo(N a, PN b) {
  return a >= 0 ? a / b : -((-a - 1) / b) - 1;
}
template <typename N, typename PN>
inline N cei(N a, PN b) {
  return a > 0 ? (a - 1) / b + 1 : -(-a / b);
}
template <typename N>
N gcd(N a, N b) {
  return b ? gcd(b, a % b) : a;
}
template <typename N>
inline int sgn(N a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
inline void gn(long long &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
inline void gn(long double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
inline void gs(char *s) { scanf("%s", s); }
inline void gc(char &c) {
  while ((c = getchar()) > 126 || c < 33)
    ;
}
inline void pc(char c) { putchar(c); }
inline long long sqr(long long a) { return a * a; }
inline long double sqrf(long double a) { return a * a; }
const int inf = 0x3f3f3f3f;
const long double pi = 3.14159265358979323846264338327950288L;
const long double eps = 1e-6;
void dis(map<int, map<int, int> > &m) {
  for (__typeof((m).begin()) it = (m).begin(); it != (m).end(); it++) {
    cout << it->first << endl;
    for (__typeof((m[it->first]).begin()) it1 = (m[it->first]).begin();
         it1 != (m[it->first]).end(); it1++) {
      cout << it1->first << " " << it1->second << endl;
    }
  }
}
int main() {
  int t = 1, case_no = 1;
  while (t--) {
    vector<pair<int, int> > a;
    int n;
    cin >> n;
    map<int, map<int, int> > m;
    for (int i = (0), _ed = (n); i < _ed; i++) {
      int x, y;
      cin >> x >> y;
      pair<int, int> p = make_pair(x, y);
      a.push_back(p);
      m[x][i] = y;
    }
    int count = 0;
    vector<int> a1, a2;
    while (m[1].size() != 0) {
      vector<pair<int, int> > q;
      vector<int> t;
      for (__typeof((m[1]).begin()) it = (m[1]).begin(); it != (m[1]).end();
           it++) {
        if (it->second == -1) continue;
        a[it->first].first = 0;
        int d = a[it->second].first;
        if (d == 0) continue;
        a1.push_back(it->first);
        a2.push_back(it->second);
        a[it->second].first = d - 1;
        int x = m[d][it->second];
        count++;
        if (d != 1) {
          m[d].erase(m[d].find(it->second));
          if (d > 2) {
            m[d - 1][it->second] = x ^ it->first;
          } else {
            q.push_back(make_pair(it->second, x ^ it->first));
          }
        } else {
          count++;
          m[1][it->second] = -1;
        }
        it->second = -1;
        if (count == n - 1) break;
      }
      if (count >= n - 1) break;
      m[1].clear();
      for (int i = (0), _ed = (q.size()); i < _ed; i++) {
        m[1][q[i].first] = q[i].second;
      }
    }
    cout << a1.size() << endl;
    for (int i = (0), _ed = (a1.size()); i < _ed; i++) {
      cout << a1[i] << " " << a2[i] << endl;
    }
  }
  return 0;
}
