#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> deg(n), s(n);
  stack<int> st;
  for (int i = 0; i < n; ++i) {
    cin >> deg[i] >> s[i];
    if (deg[i] == 1) st.push(i);
  }
  vector<pair<int, int>> ans;
  while (!st.empty()) {
    int u = st.top();
    st.pop();
    if (deg[u] == 0) continue;
    int v = s[u];
    s[u] = 0;
    s[v] ^= u;
    --deg[u];
    --deg[v];
    ans.emplace_back(u, v);
    if (deg[v] == 1) st.push(v);
  }
  cout << ans.size() << '\n';
  for (auto [u, v] : ans) {
    cout << u << ' ' << v << '\n';
  }
  return 0;
}
