END { load __FILE__ unless $stdin.eof? }

class DSU
  def initialize(n = 0)
    @n = n
    @parent_or_size = Array.new(n, -1)
  end

  def merge(a, b)
    x, y = leader(a), leader(b)
    return x if x == y

    x, y = y, x if -@parent_or_size[x] < -@parent_or_size[y]
    @parent_or_size[x] += @parent_or_size[y]
    @parent_or_size[y] = x
  end

  def same(a, b)
    leader(a) == leader(b)
  end

  def leader(a)
    return a if @parent_or_size[a] < 0

    @parent_or_size[a] = leader(@parent_or_size[a])
  end

  def size(a)
    -@parent_or_size[leader(a)]
  end

  def groups
    @n.times.group_by { |i| leader(i) }.values
  end
end

n = gets.to_i
towns = Array.new(n) { |i| gets.split.map!(&:to_i) << i }.sort!

graph = DSU.new(n)
while (tx, ty, tid = towns.shift)
  tymax = n
  loop do
    town = towns.find { |x, y| y > ty && y <= tymax }
    break unless town
    graph.merge(tid, town[2])
    tymax = town[1] - 1
  end
end

leaders = n.times.map(&graph.method(:leader))
histogram = leaders.tally

n.times { |i| puts histogram[leaders[i]] }
