// Abhay Singh Bhadoria ( _Asb_ ) //
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct S {
int x, y, pos;
bool operator < (S a) {
if(x == a.x) return y < a.y;
else return x < a.x;
}
} ratings[3 * N];
int bit[N];
int res[3 * N];
void update(int x) {
while(x <= 1e5) {
bit[x]++;
x += x & (-x);
}
}
int query(int x) {
int res = 0;
while(x > 0) {
res += bit[x];
x -= x & (-x);
}
return res;
}
int main() {
ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> ratings[i].x >> ratings[i].y;
ratings[i].pos = i;
}
sort(ratings, ratings + n);
for(int i = 0; i < n; ++i) {
int inc = query(ratings[i].y);
int same = i;
while(same < n && ratings[i].x == ratings[same].x && ratings[i].y == ratings[same].y) {
res[ratings[same].pos] = inc;
update(ratings[i].y);
++same;
}
i = same - 1;
}
for(int i = 0; i < n; ++i) cout << res[i] << '\n';
}
Ly8gQWJoYXkgU2luZ2ggQmhhZG9yaWEgKCBfQXNiXyApIC8vCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMWU1ICsgNTsKc3RydWN0IFMgewogICAgaW50IHgsIHksIHBvczsKICAgIGJvb2wgb3BlcmF0b3IgPCAoUyBhKSB7CiAgICAgICAgaWYoeCA9PSBhLngpIHJldHVybiB5IDwgYS55OwogICAgICAgIGVsc2UgcmV0dXJuIHggPCBhLng7CiAgICB9Cn0gcmF0aW5nc1szICogTl07CmludCBiaXRbTl07CmludCByZXNbMyAqIE5dOwp2b2lkIHVwZGF0ZShpbnQgeCkgewogICAgd2hpbGUoeCA8PSAxZTUpIHsKICAgICAgICBiaXRbeF0rKzsKICAgICAgICB4ICs9IHggJiAoLXgpOwogICAgfQp9CmludCBxdWVyeShpbnQgeCkgewogICAgaW50IHJlcyA9IDA7CiAgICB3aGlsZSh4ID4gMCkgewog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