using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	
	public void Solve(){
		
		int[] ord = new int[N + 1];
		for(int i=0;i<N;i++) ord[X[i]] = i;
		Array.Sort(X, Y);
		
		var UF = new UnionFind(N, Y);
		var ST = new SegTreeMax(N);
		for(int i=0;i<N;i++){
			ST.Update(i, Y[i]);
		}
		
		for(int i=0;i<N;i++){
			int ymin = UF.Min(i);
			int idx = ST.FindLeftMost(i + 1, N, ymin);
			//Console.WriteLine("i:{0}, X[i]:{1}, Y[i]:{2}, ymin:{3}, idx:{4}",i,X[i],Y[i],ymin,idx);
			if(idx == -1) continue;
			UF.Unite(i, idx);
		}
		
		int[] ans = new int[N];
		for(int i=0;i<N;i++) ans[i] = UF.MemCnt(i);
		int[] ans2 = new int[N];
		for(int i=0;i<N;i++) ans2[ord[X[i]]] = ans[i];
		
		
		Console.WriteLine(String.Join("\n", ans2));
		
		
		
	}
	int N;
	int[] X,Y;
	public Sol(){
		N = ri();
		X = new int[N];
		Y = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}



class SegTreeMax{
	//segment Tree 
	// 0-origin
	protected int[] Data;	
	protected int Inf;	
	protected int N;		
	protected int n;		
	
	public SegTreeMax(int n_){
		N = n_; Inf = (int)1e9;
		n = 1;
		while(n < n_) n *= 2;
		Data = new int[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = -Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k,int a){
		k+=n-1;	
		Data[k]=a;
		while(k>0){
			k=(k-1)/2;
			Data[k]=Math.Max(Data[k*2+1],Data[k*2+2]);
		}
	}
	
	
	public int QueryMax(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	//RMQ; [a,b)
	public int Query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return Inf;
		if(a <= l && r <= b) return Data[k];
		
		var vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
		var vr = Query(a ,b, k * 2 + 2, (l + r) / 2, r);
		return Math.Max(vl, vr);
	}
	
	
	public int FindLeftMost(int a, int b, int v){
		return FindLeftMost(a, b, v, 0, 0, n);
	}
	int FindLeftMost(int a, int b, int v, int k, int l, int r){
		//Console.WriteLine("a:{0}, b;{1}, v:{2}, k;{3}, l;{4}, r:{5}, Data[k];{6}",a,b,v,k,l,r,Data[k]);
		if(Data[k] < v) return -1;
		if(r <= a || b <= l) return -1;
		if(k >= n - 1) return k - (n - 1);
		
		var ret = FindLeftMost(a, b, v, k * 2 + 1, l, (l + r) / 2);
		if(ret == -1) return FindLeftMost(a, b, v, k * 2 + 2, (l + r) / 2, r);
		else return ret;
		
	}
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}

class UnionFind{
	
	int[] parent;
	int[] mem;
	int[] min;
	int compo;
	int N;
	public UnionFind(int n_, int[] mi_){
		Initialize(n_, mi_);
	}
	
	public void Initialize(int n_, int[] mi){
		N=n_;
		parent = new int[N];
		mem = new int[N];
		min = new int[N];
		for(int i=0;i<N;i++){
			parent[i]=i;
			mem[i]=1;
			min[i] = mi[i];
		}
		compo=N;
	}
	
	
	public int Parent(int a){
		if(parent[a]==a) return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a == b) return;
		if(mem[a] > mem[b]){var t = a; a = b; b = t;}
		parent[a] = b;
		mem[b] += mem[a];
		min[b] = Math.Min(min[b], min[a]);
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	public int Min(int x){
		return min[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i==0?"{0}":" {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


Measured memory_bytes: 51568