import heapq

from collections import deque



def bfs(i, c):

    color[i] = c

    cnt[c] += 1

    q = deque()

    q.append(i)

    while q:

        j = q.popleft()

        for k in G[j]:

            if color[k] == -1:

                color[k] = c

                cnt[c] += 1

                q.append(k)

    return



n = int(eval(input()))

xy = []

for i in range(n):

    x, y = list(map(int, input().split()))

    xy.append([x, y, i])

xy.sort()

cnt = [0] * n

h = [[n + 1, n + 1]]

G = []

for _ in range(n):

    G.append([])

for i in range(n):

    c = 0

    while h[0][0] < xy[i][1]:

        p = heapq.heappop(h)

        if c == 0:

            minv = p

        c = 1

        G[p[1]].append(xy[i][2])

        G[xy[i][2]].append(p[1])

    #heapq.heappush(h, [xy[i][1], xy[i][2]])

    if c:

        heapq.heappush(h, minv)

    else:

        heapq.heappush(h, [xy[i][1], xy[i][2]])

color = [-1] * n

c = 0

for i in range(n):

    if color[i] == -1:

        bfs(i, c)

        c += 1

for i in range(n):

    ans = cnt[color[i]]

    print(ans)
import heapq

from collections import deque



def bfs(i, c):

    color[i] = c

    cnt[c] += 1

    q = deque()

    q.append(i)

    while q:

        j = q.popleft()

        for k in G[j]:

            if color[k] == -1:

                color[k] = c

                cnt[c] += 1

                q.append(k)

    return



n = int(eval(input()))

xy = [0] * n

for i in range(n):

    x, y = list(map(int, input().split()))

    xy[x - 1] = [x, y, i]

cnt = [0] * n

h = [[n + 1, n + 1]]

G = []

for _ in range(n):

    G.append([])

for i in range(n):

    c = 0

    while h[0][0] < xy[i][1]:

        p = heapq.heappop(h)

        if c == 0:

            minv = p

        c = 1

        G[p[1]].append(xy[i][2])

        G[xy[i][2]].append(p[1])

    #heapq.heappush(h, [xy[i][1], xy[i][2]])

    if c:

        heapq.heappush(h, minv)

    else:

        heapq.heappush(h, [xy[i][1], xy[i][2]])

color = [-1] * n

c = 0

for i in range(n):

    if color[i] == -1:

        bfs(i, c)

        c += 1

for i in range(n):

    ans = cnt[color[i]]

    print(ans)
import heapq
from collections import deque


def bfs(i, c):
    color[i] = c
    cnt[c] += 1
    q = deque()
    q.append(i)
    while q:
        j = q.popleft()
        for k in G[j]:
            if color[k] == -1:
                color[k] = c
                cnt[c] += 1
                q.append(k)
    return


n = int(eval(input()))
xy = []
for i in range(n):
    x, y = list(map(int, input().split()))
    xy.append([x, y, i])
xy.sort()
cnt = [0] * n
h = [[n + 1, n + 1]]
G = []
for _ in range(n):
    G.append([])
for i in range(n):
    c = 0
    while h[0][0] < xy[i][1]:
        p = heapq.heappop(h)
        if c == 0:
            minv = p
        c = 1
        G[p[1]].append(xy[i][2])
        G[xy[i][2]].append(p[1])
    # heapq.heappush(h, [xy[i][1], xy[i][2]])
    if c:
        heapq.heappush(h, minv)
    else:
        heapq.heappush(h, [xy[i][1], xy[i][2]])
color = [-1] * n
c = 0
for i in range(n):
    if color[i] == -1:
        bfs(i, c)
        c += 1
for i in range(n):
    ans = cnt[color[i]]
    print(ans)

import heapq
from collections import deque


def bfs(i, c):
    color[i] = c
    cnt[c] += 1
    q = deque()
    q.append(i)
    while q:
        j = q.popleft()
        for k in G[j]:
            if color[k] == -1:
                color[k] = c
                cnt[c] += 1
                q.append(k)
    return


n = int(eval(input()))
xy = [0] * n
for i in range(n):
    x, y = list(map(int, input().split()))
    xy[x - 1] = [x, y, i]
cnt = [0] * n
h = [[n + 1, n + 1]]
G = []
for _ in range(n):
    G.append([])
for i in range(n):
    c = 0
    while h[0][0] < xy[i][1]:
        p = heapq.heappop(h)
        if c == 0:
            minv = p
        c = 1
        G[p[1]].append(xy[i][2])
        G[xy[i][2]].append(p[1])
    # heapq.heappush(h, [xy[i][1], xy[i][2]])
    if c:
        heapq.heappush(h, minv)
    else:
        heapq.heappush(h, [xy[i][1], xy[i][2]])
color = [-1] * n
c = 0
for i in range(n):
    if color[i] == -1:
        bfs(i, c)
        c += 1
for i in range(n):
    ans = cnt[color[i]]
    print(ans)

-xy = [] +xy = [0] * n -    xy.append([x, y, i]) -xy.sort() +    xy[x - 1] = [x, y, i]