#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int c[200005],pre[200005];
pair<int,int> p[200005],a[200005];
int find(int x){
    return (x==pre[x])?x:(pre[x]=find(pre[x]));   
}
void merge(int x,int y){
    pre[find(x)]=find(y);
}
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i].first>>p[i].second;pre[i]=i;
        a[i].first=p[i].first;a[i].second=p[i].second;
    }
    sort(p+1,p+1+n);
    stack<int> s;
    for(int i=1;i<=n;i++){
        if(s.size()==0||p[i].second<s.top()){
            s.push(p[i].second);
        }
        else{
            int v=s.top();
            while(s.size()&&s.top()<p[i].second){
                merge(p[i].second,s.top());s.pop();
            }
            s.push(v);
        }
    }
    for(int i=1;i<=n;i++){
        c[find(i)]++;
    }
    for(int i=1;i<=n;i++){
        cout<<c[find(a[i].second)]<<endl;
    }
}