package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"

	"github.com/emirpasic/gods/trees/binaryheap"
	"github.com/emirpasic/gods/utils"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	pp := make([][3]int, n)
	mm := map[int]int{}
	for i := 0; i < n; i++ {
		pp[i][0] = getNextInt(scanner) - 1
		pp[i][1] = getNextInt(scanner) - 1
		pp[i][2] = i
		mm[pp[i][1]] = pp[i][2]
	}
	sort.Slice(pp, func(i, j int) bool {
		return pp[i][0] < pp[j][0]
	})
	d := NewDsu(n)
	bh := binaryheap.NewWithIntComparator()
	for i := 0; i < n; i++ {
		if bh.Empty() {
			bh.Push(pp[i][1])
			continue
		}
		p, _ := bh.Peek()
		if p.(int) > pp[i][1] {
			bh.Push(pp[i][1])
			continue
		}
		rev := p.(int)
		for j := rev; !bh.Empty() && j < pp[i][1]; {
			d.Merge(pp[i][2], mm[j])
			bh.Pop()
			if !bh.Empty() {
				x, _ := bh.Peek()
				j = x.(int)
			}
		}
		bh.Push(rev)
	}
	bh = binaryheap.NewWith(func(a, b interface{}) int {
		return -utils.IntComparator(a, b)
	})
	for i := n - 1; i >= 0; i-- {
		if bh.Empty() {
			bh.Push(pp[i][1])
			continue
		}
		p, _ := bh.Peek()
		if p.(int) < pp[i][1] {
			bh.Push(pp[i][1])
			continue
		}
		rev := p.(int)
		for j := rev; !bh.Empty() && j > pp[i][1]; {
			d.Merge(pp[i][2], mm[j])
			bh.Pop()
			if !bh.Empty() {
				x, _ := bh.Peek()
				j = x.(int)
			}
		}
		bh.Push(rev)
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, d.Size(i))
	}
}

// Dsu Data structures and algorithms for disjoint set union problems
type Dsu struct {
	n            int
	parentOrSize []int
}

// NewDsu Constructor
func NewDsu(n int) *Dsu {
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = -1
	}
	return &Dsu{parentOrSize: p, n: n}
}

// Merge adds an edge (a, b).
func (d *Dsu) Merge(a, b int) int {
	x := d.Leader(a)
	y := d.Leader(b)
	if x == y {
		return x
	}
	if d.parentOrSize[x] > d.parentOrSize[y] {
		x, y = y, x
	}
	d.parentOrSize[x] += d.parentOrSize[y]
	d.parentOrSize[y] = x
	return x
}

// Same returns whether the vertices a and b are in the same connected component.
func (d *Dsu) Same(a, b int) bool {
	return d.Leader(a) == d.Leader(b)
}

// Leader returns the representative of the connected component that contains the vertex a.
func (d *Dsu) Leader(a int) int {
	if d.parentOrSize[a] < 0 {
		return a
	}
	d.parentOrSize[a] = d.Leader(d.parentOrSize[a])
	return d.parentOrSize[a]
}

// Size returns the size of the connected component that contains the vertex a.
func (d *Dsu) Size(a int) int {
	return -d.parentOrSize[d.Leader(a)]
}

// Groups divides the graph into connected components and returns the list of them.
func (d *Dsu) Groups() [][]int {
	result := make([][]int, d.n)
	for i := 0; i < d.n; i++ {
		l := d.Leader(i)
		result[l] = append(result[l], i)
	}
	return result
}


Measured memory_bytes: 26792