#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
const int N = 2e6 + 1;
int deg[N], s[N];
bool vis[N];
int main() {
  queue<int> q;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> s[i];
    if (deg[i] == 1) q.push(i);
  }
  vector<pair<int, int> > vp;
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    if (vis[top]) continue;
    vp.push_back({top, s[top]});
    deg[top]--;
    deg[s[top]]--;
    vis[top] = 1;
    if (deg[s[top]] == 0)
      vis[s[top]] = 1;
    else
      s[s[top]] ^= top;
    if (deg[s[top]] == 1) q.push(s[top]);
  }
  cout << vp.size() << "\n";
  for (auto x : vp) cout << x.first << " " << x.second << "\n";
  return 0;
}
