class UnionFind
  def initialize(n)
    @size = Array.new(n, 1)
    @rank = Array.new(n, 0)
    @parent = []

    (0..n).each do |i|
      @parent[i] = i
    end
  end

  def find(x)
    if @parent[x] == x
      x
    else
      @parent[x] = find(@parent[x])
    end
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y

    if @rank[x] < @rank[y]
      @parent[x] = y
      @size[y] += @size[x]
    else
      @parent[y] = x
      @size[x] += @size[y]

      @rank[x] += 1 if @rank[x] == @rank[y]
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def size(x)
    @size[find(x)]
  end
end

N = gets.to_i
P = N.times.map { |i| [i] + gets.split.map(&:to_i) }
P.sort_by! { |id, x, y| x }

uf = UnionFind.new(N + 1)
ans = Array.new(N, 1)
stack = [[-1, -Float::INFINITY]]

P.each do |id, x, y|
  # p [:id, id, :y, y, :x, x, :cnt, cnt]

  while stack.last.last > y
    stack.pop
  end

  uid = stack.last.first

  if uid != -1
    uf.unite(id, uid)
  end

  stack.push([id, y])
end

stack = [[-1, Float::INFINITY]]

P.reverse_each do |id, x, y|
  while stack.last.last < y
    stack.pop
  end

  uid = stack.last.first

  if uid != -1
    uf.unite(id, uid)
  end

  stack.push([id, y])
end

puts (0...N).map { |x| uf.size(x) }
