#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 77;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-9; }
int d[1 << 17], s[1 << 17];
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  ;
  int n;
  cin >> n;
  stack<pii> st;
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) st.push({s[i], i});
  }
  vpii v;
  for (int i = 0; i < n; ++i) {
    if (st.empty()) break;
    int u = st.top().first;
    int w = st.top().second;
    st.pop();
    if (d[w] == 0) continue;
    d[u]--;
    s[u] ^= w;
    v.push_back({u, w});
    if (d[u] == 1) st.push({s[u], u});
  }
  cout << ((int)(v).size()) << '\n';
  for (pii u : v) {
    cout << u.first << " " << u.second << '\n';
  }
  return 0;
}
int32_t main() {
  solve();
  return 0;
}
