#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int degree[n], xorsum[n];
queue <int> Q;
int used = 0;
for(int i = 0; i < n; ++i)
{
cin >> degree[i] >> xorsum[i];
if (degree[i] == 1)
Q.push(i);
if (degree[i] == 0)
{
if (xorsum[i] != 0)
assert(false);
used++;
}
}
vector < pair<int, int> > ans;
while(!Q.empty())
{
int from = Q.front();
Q.pop();
used++;
if (degree[from] == 0)
{
if (xorsum[from] != 0)
assert(false);
continue;
}
degree[from]--;
int to = xorsum[from];
xorsum[from] = 0;
if (to >= n)
assert(false);
ans.push_back(make_pair(from, to));
xorsum[to] ^= from;
if (degree[to] == 0)
assert(false);
degree[to]--;
if (degree[to] == 1)
Q.push(to);
}
if (used != n)
assert(false);
cout << ans.size() << endl;
for(size_t i = 0; i < ans.size(); ++i)
cout << ans[i].first << " " << ans[i].second << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgaW50IGRlZ3JlZVtuXSwgeG9yc3VtW25dOwogICAgcXVldWUgPGludD4gUTsKICAgIGludCB1c2VkID0gMDsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiAgICB7CiAgICAJY2luID4+IGRlZ3JlZVtpXSA+PiB4b3JzdW1baV07CiAgICAJaWYgKGRlZ3JlZVtpXSA9PSAxKQogICAgCQlRLnB1c2goaSk7CiAgICAJaWYgKGRlZ3JlZVtpXSA9PSAwKQogICAgCXsKICAgIAkJaWYgKHhvcnN1bVtpXSAhPSAwKQogICAgCQkJYXNzZXJ0KGZhbHNlKTsKICAgIAkJdXNlZCsrOwogICAgCX0KICAgIH0KICAgIHZlY3RvciA8IHBhaXI8aW50LCBpbnQ+ICA+IGFuczsKICAgIHdoaWxlKCFRLmVtcHR5KCkpCiAgICB7CiAgICAJaW50IGZyb20gPSBRL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