import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val xs = IntArray(n + 1)
    val ys = IntArray(n + 1)
    for (j in 1..n) {
        val (x, y) = jin.readLine().split(" ").map { it.toInt() }
        xs[j] = x
        ys[j] = y
    }
    val zs = (1..n).sortedBy { xs[it] }
    val union = IntArray(n + 1) { it }
    val uStack = Stack<Int>()
    fun getUnion(u: Int): Int {
        uStack.push(u)
        while (union[uStack.peek()] != union[union[uStack.peek()]]) {
            uStack.push(union[uStack.peek()])
        }
        val v = union[uStack.pop()]
        while (uStack.isNotEmpty()) {
            union[uStack.pop()] = v
        }
        return v
    }
    val stack = Stack<Int>()
    for (z in zs) {
        val m = if (stack.isEmpty() || ys[z] < ys[stack.peek()]) z else stack.peek()
        while (stack.isNotEmpty() && ys[z] > ys[stack.peek()]) {
            union[getUnion(stack.pop())] = getUnion(z)
        }
        stack.push(m)
    }
    val amts = IntArray(n + 1)
    for (j in 1..n) {
        amts[getUnion(j)]++
    }
    val joiner = StringJoiner("\n")
    for (j in 1..n) {
        joiner.add(amts[getUnion(j)].toString())
    }
    println(joiner)
}