#include <bits/stdc++.h>
const long long int INF = 2e15;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> d(n), s(n);
  vector<int> st;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) st.push_back(i);
  }
  vector<pair<int, int> > edge;
  while (!st.empty()) {
    int id = st.back();
    st.pop_back();
    if (d[id] < 1) continue;
    edge.push_back(make_pair(id, s[id]));
    d[s[id]]--;
    s[s[id]] ^= id;
    if (d[s[id]] == 1) st.push_back(s[id]);
  }
  cout << (int)(edge).size() << endl;
  for (int(i) = 0; (i) < ((int)(edge).size()); (i)++)
    cout << edge[i].first << " " << edge[i].second << endl;
}
