#include <cstdio>
#include <algorithm>
typedef long long ll;
const int M = 200010;
int n;
int x[M],y[M],a[M],d[M],ans[M],top = 0;

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n);
    for(int i = 1;i <= n; i++) read(x[i]), read(y[i]), a[x[i]] = y[i];
    int m = n + 1;
    for(int i = 1;i <= n; i++){
        m = std::min(m,a[i]);
        if(m == n - i + 1) d[++top] = i;//每一个连接的起始点
    }
    for(int i = 1;i <= top; i++)
        for(int j = d[i];j > d[i - 1]; j--)
            ans[j] = d[i] - d[i - 1];//枚举每一个连接
    for(int i = 1;i <= n; i++) printf("%d\n",ans[x[i]]);
    return 0;
}