#include <bits/stdc++.h>
/* MACROS */
#define all(A) (A).begin() , (A).end()
#define rall(A) (A).rbegin() , (A).rend()
#define sz(A) (int)(A).size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ln(X) (int)(X).length()
#define square(X) ((X)*(X))
#define cube(X) ((X)*(X)*(X))
#define y1 thisisnotnonsenseasyoumaythink
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forr(i, n) for (int i = int(n - 1); i >= 0; i--)
#define fora(i, a, b) for (int i = int(a); i <= int(b); i++)
#define forb(i, a, b) for (int i = int(a); i >= int(b); i--)
#define fore(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define dbg(vari) cerr << #vari << " = " << (vari) << endl
#define dbg2(vari) cerr << #vari << " = " << (vari) << ", "
#define prt(vari) cerr << (vari) << endl
#define prt2(vari) cerr << (vari) << ", "
using namespace std;
/* TYPE DEFINITIONS */
typedef long long i64;
typedef vector<int> vi;
typedef pair<int,int> pi;
/* TOOLS */
template <class T> void debug(T a,T b){ for (; a != b; a++) cerr << *a << ' '; cerr << endl; }
#define ID second
#define SCR1 first.first
#define SCR2 first.second
int n;
pair<pi, int> scr[500010];
int hiest[500010];
int loest[500010];
struct fenwick {
int cum[710];
fenwick() {
fill(cum, cum+710, 0);
}
void add(int idx, int val) {
for (; idx <= 700; idx = (idx|(idx+1)))
cum[idx] += val;
}
int get(int idx) {
int ret = 0;
for (; idx >= 0; idx = (idx&(idx+1))-1)
ret += cum[idx];
return ret;
}
};
fenwick f1;
fenwick f2;
fenwick f3;
fenwick f4;
int main()
{
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> scr[i].SCR1;
cin >> scr[i].SCR2;
scr[i].SCR1 += 2;
scr[i].SCR2 += 2;
scr[i].ID = i;
}
sort(scr, scr+n);
for (int i = n-1; i >= 0;) {
int j = i;
while (j >= 0 && scr[i].SCR1 == scr[j].SCR1) {
hiest[ scr[j].ID ] = 1;
hiest[ scr[j].ID ] += f1.get(700) - f1.get(scr[j].SCR2);
j--;
}
for (int k = j+1; k <= i; k++)
f1.add(scr[k].SCR2, 1);
i = j;
}
for (int i = 0; i < n; i++) {
if (scr[i].SCR1 == 2)
f3.add(scr[i].SCR2, 1);
if (scr[i].SCR2 == 2)
f4.add(scr[i].SCR1, 1);
}
for (int i = 0; i < n;) {
int j = i;
while (j < n && scr[i].SCR1 == scr[j].SCR1) {
loest[ scr[j].ID ] = n;
loest[ scr[j].ID ] -= f2.get(scr[j].SCR2-1);
if (scr[j].SCR1 == 652)
loest[ scr[j].ID ] -= (f3.get(scr[j].SCR2) - f3.get(scr[j].SCR2-1));
if (scr[j].SCR2 == 652)
loest[ scr[j].ID ] -= (f4.get(scr[j].SCR1) - f4.get(scr[j].SCR1-1));
j++;
}
for (int k = i; k < j; k++)
f2.add(scr[k].SCR2, 1);
i = j;
}
for (int i = 0; i < n; i++) {
cout << hiest[i] << " ";
cout << loest[i] << "\n";
}
return EXIT_SUCCESS;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Ci8qIE1BQ1JPUyAqLwoKI2RlZmluZSAgYWxsKEEpCQkJKEEpLmJlZ2luKCkgLCAoQSkuZW5kKCkKI2RlZmluZSAgcmFsbChBKQkJKEEpLnJiZWdpbigpICwgKEEpLnJlbmQoKQojZGVmaW5lICBzeihBKQkJCShpbnQpKEEpLnNpemUoKQojZGVmaW5lICBwYgkJCQlwdXNoX2JhY2sKI2RlZmluZSAgcHBiCQkJcG9wX2JhY2sKI2RlZmluZSAgbXAJCQkJbWFrZV9wYWlyCiNkZWZpbmUgIGxuKFgpCQkJKGludCkoWCkubGVuZ3RoKCkKI2RlZmluZSAgc3F1YXJlKFgpCQkoKFgpKihYKSkKI2RlZmluZSAgY3ViZShYKQkJKChYKSooWCkqKFgpKQojZGVmaW5lICB5MQkJCQl0aGlzaXNub3Rub25zZW5zZWFzeW91bWF5dGhpbmsKI2RlZmluZSAgZm9ybihpLC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