You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.

Your task is the following: for every $k \in [1..n]$, calculate the number of points with integer coordinates such that the number of segments that cover these points equals $k$. A segment with endpoints $l_i$ and $r_i$ covers point $x$ if and only if $l_i \le x \le r_i$.


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of segments.

The next $n$ lines contain segments. The $i$-th line contains a pair of integers $l_i, r_i$ ($0 \le l_i \le r_i \le 10^{18}$) — the endpoints of the $i$-th segment.


-----Output-----

Print $n$ space separated integers $cnt_1, cnt_2, \dots, cnt_n$, where $cnt_i$ is equal to the number of points such that the number of segments that cover these points equals to $i$.


-----Examples-----
Input
3
0 3
1 3
3 8

Output
6 2 1 

Input
3
1 3
2 4
5 7

Output
5 2 0 



-----Note-----

The picture describing the first example:

[Image]

Points with coordinates $[0, 4, 5, 6, 7, 8]$ are covered by one segment, points $[1, 2]$ are covered by two segments and point $[3]$ is covered by three segments.

The picture describing the second example:

[Image]

Points $[1, 4, 5, 6, 7]$ are covered by one segment, points $[2, 3]$ are covered by two segments and there are no points covered by three segments.

Difficulty: interview

Starter code:

Solutions:
3

def solve(N, A):
    cnt = [0] * (N + 1)

    evd = {}
    xs = []
    for a, b in A:
        if a not in evd:
            evd[a] = [0, 0]
            xs.append(a)
        if b not in evd:
            evd[b] = [0, 0]
            xs.append(b)

        evd[a][0] += 1
        evd[b][1] += 1

    xs.sort()

    px = xs[0] - 1
    pop = 0
    for x in xs:
        cnt[pop] += x - px - 1
        cnt[pop + evd[x][0]] += 1
        pop -= evd[x][1]
        pop += evd[x][0]
        px = x

    return cnt[1:]


def main():
    N = int(input())
    A = [tuple([int(e) for e in input().split(' ')]) for _ in range(N)]
    print(*solve(N, A))


def __starting_point():
    main()

__starting_point()

from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque


def read():
    return int(input())


def readmap():
    return list(map(int, input().split()))


def readlist():
    return list(map(int, input().split()))


# C
N = read()
LIST = []
left = 0
right = 1
for i in range(N):
    l, r = readmap()
    LIST.append((l, left))
    LIST.append((r, right))

LIST.sort()

cnt = [0] * (N+1)  # DO NOT USE cnt[0]

n = 1
x = LIST[0][0]
dir = left
for item in LIST[1:]:
    if item[1] == left:
        if dir == left:
            cnt[n] += item[0] - x
            n += 1
            x = item[0]
            dir = left
        else:
            cnt[n] += item[0] - x - 1
            n += 1
            x = item[0]
            dir = left
    else:
        if dir == left:
            cnt[n] += item[0] - x + 1
            n -= 1
            x = item[0]
            dir = right
        else:
            cnt[n] += item[0] - x
            n -= 1
            x = item[0]
            dir = right

print(" ".join(list(map(str, cnt[1:]))))



from collections import defaultdict

ans = defaultdict(int)
n = int(input())

beg, end = [0] * n, [0] * n

for i in range(n):
    a, b = map(int, input().split())
    beg[i] = a
    end[i] = b + 1
beg.sort()
end.sort()

pa, pb = 0, 0

cur = 0
lst = -1

while pb < n:
    pos = end[pb]
    if pa < n:
        pos = min(pos, beg[pa])

    ans[cur] += pos - lst

    ad = 0
    mn = 0
    while (pa < n and beg[pa] == pos):
        ad += 1
        pa += 1
    while (pb < n and end[pb] == pos):
        pb += 1
        mn -= 1

    lst = pos
    cur += ad + mn

for i in range(1, n + 1):
    print(ans[i], end = ' ')

point = {}

n = int(input())

for i in range(n):
    l, r = map(int, input().split())
    r += 1
    if l not in point:
        point[l] = 0
    if r not in point:
        point[r] = 0
    point[l] += 1
    point[r] -= 1

line = []
for key in point:
    line.append((key,point[key]))
line.sort()
ans = [0] * (n+1)

last_index = 0
last_value = 0

for index, value in line:
    ans[last_value] += index - last_index
    last_index = index
    last_value += value

for cnt in ans[1:]:
    print(cnt,end=' ')

from collections import defaultdict
n = int(input())
arr = defaultdict(int)
for a0 in range(n):
	l,r = input().strip().split()
	l,r=int(l),int(r)
	arr[l]+=1
	arr[r+1]-=1

brr=[0]*(n+1)

l=sorted(arr.keys())
sum=arr[l[0]]
prevpoint=l[0]
for key in l[1:]:
	brr[sum]+=key-prevpoint
	prevpoint=key
	sum+=arr[key]
print(*brr[1:])

n = int(input())
from collections import defaultdict, Counter
a = defaultdict(list)
count_left = Counter()
count_right = Counter()

for _ in range(n):
	l, r = map(int, input().split())
	count_left[l] += 1
	count_right[r] += 1

count = [0] * (n + 1)


pts = sorted(set(count_left.keys()) | set(count_right.keys()))
# pts.append(pts[-1])
c = 0
prev = pts[0]
for pt in pts:
	# print(prev, pt, c)
	if count_left[pt]:
		count[c] += pt - prev - 1		
		c += count_left[pt]
		count[c] += 1
		c -= count_right[pt]
	else:
		count[c] += pt - prev
		c -= count_right[pt]

	

	prev = pt
	# print(count)

print(' '.join(map(str, count[1:])))

n = int(input())
left = []
right = []
for i in range(n):
	data = input().split()
	left.append(int(data[0]))
	right.append(int(data[1]))
	
left.sort()
right.sort()
i = 0
j = 0
count = 1
ans = [0] * (n + 1)
left += [max(right) + 1]
right += [max(right) + 2]
while (i < n) and (j < n):
	while left[i + 1] <= right[j]:
		ans[count] += (left[i + 1] - left[i])
		count += 1
		i += 1
	ans[count] += (right[j] - left[i] + 1)
	i += 1	
	count -= 1
	
	while ((i == n) or (right[j + 1] < left[i])) and (j < n - 1):
		ans[count] += (right[j + 1] - right[j])
		count -= 1
		j += 1
	ans[count] += (left[i] - right[j] - 1)
	j += 1
	count += 1
#	print(i, j)

	
for i in range(1, n + 1):
	print(ans[i], end = " ")
print()
	


from collections import defaultdict
n, s = int(input()), []
for i in range(n):
  a = [int(x) for x in input().split()]
  s += [(a[0], 0), (a[1], 1)]
s.sort()
now = 0
rev = defaultdict(int)
for a,b in zip(s, s[1:]):
  # print(a,b)
  if(a[1] == 0):
    now += 1
    # print("now: %d" % now)
    rev[now] += b[0] - a[0]
    if b[1] == 1: 
      # print("add %d" % (b[0] - a[0] + 1))
      rev[now] += 1
    # else:
    #   print("add %d" % (b[0] - a[0]))
  else:
    now -= 1
    # print("now: %d" % now)
    if b[0] != a[0]: 
      rev[now] += b[0] - a[0]
      if b[1] == 0: 
        # print("add %d" % (b[0] - a[0] - 1))
        rev[now] -= 1
      # else:
      #   print("add %d" % (b[0] - a[0]))
# print(rev)
for i in range(1, n+1):
  print(rev[i], end=" ")

from collections import defaultdict
n, s= int(input()), []
for i in range(n):
  a = [int(x) for x in input().split()]
  s += [(a[0], 0), (a[1], 1)]
s.sort()
now, rev = 0, defaultdict(int)
for a, b in zip(s, s[1:]):
  now += 1 if a[1] == 0 else -1
  if(a[1] == 0):
    rev[now] += b[0] - a[0] + (1 if b[1] == 1 else 0)
  elif b[0] != a[0]:
    rev[now] += b[0] - a[0] - (1 if b[1] == 0 else 0)
[print(rev[i], end=" ") for i in range(1, n+1)]


n=int(input())
a=[]
for i in range(n):
    l,r=list(map(int,input().split()))
    a.append([l,1])
    a.append([r+1,-1])
a.sort()

c=0
ans=[0]*(n+1)
for i in range(2*n):
    c+=a[i][1]
    if (i+1)<len(a) and a[i][0]!=a[i+1][0]:
        ans[c]+=a[i+1][0]-a[i][0]

print(*ans[1:])


n = int(input())
l = []
for i in range(n):
    a,b = map(int,input().split())
    l.append((a,1))
    l.append((b+1,0))
l.sort()
ans = [0 for i in range(n+1)]
val = 0;
for i in range(2*n-1):
    if(l[i][1]==1):
        val += 1
    else:
        val -= 1
    ans[val] += l[i+1][0] - l[i][0]
for i in ans[1:]:
    print(i,' ',sep='',end='')



def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())
from collections import Counter

n = ii()
a1 = [tuple(mi()) for i in range(n)]
a = []
for l, r in a1:
    a.append((l, 0))
    a.append((r, 1))
c = Counter(a)
b = [(k[0], k[1], v) for k, v in c.items()]
b.sort()
ans = [0] * (n + 1)
p = -1
cnt = 0
for x, y, z in b:
    if y == 0:
        ans[cnt] += x - p - 1
        cnt += z
        ans[cnt] += 1
    else:
        if x != p:
            ans[cnt] += x - p
        cnt -= z
    p = x
print(*ans[1:])

n=int(input())
a=[]
for i in range(n):
	l,r=map(int,input().split())
	a.append([l,1])
	a.append([r+1,-1])
a.sort()
# print(a)
ans=[0]*(n+1)
idx=0
for i in range(len(a)-1):
	idx+=a[i][1]
	ans[idx]+=a[i+1][0]-a[i][0]
for i in range(1,n+1):
	print(ans[i],end=" ")
print()

from collections import defaultdict

n = int(input())
arr = defaultdict(int)

for a0 in range(n):
    l, r = input().strip().split()
    l, r = int(l), int(r)
    arr[l] += 1
    arr[r + 1] -= 1

brr = [0] * (n + 1)

l = sorted(arr.keys())
sum = arr[l[0]]
prevpoint = l[0]

for key in l[1:]:
    brr[sum] += key - prevpoint
    prevpoint = key
    sum += arr[key]

print(*brr[1:])


n = int(input())
pos = {}
for _ in range(n):
    L, R = list(map(int, input().split()))
    if L in pos: pos[L] += 1
    else: pos[L] = 1
    if R+1 in pos: pos[R+1] -= 1
    else: pos[R+1] = -1
a = sorted(list(pos.items()), key=lambda x: x[0])
res = [0]*n
s = 0
for i in range(len(a)):
    if 1 <= s <= n:
        res[s - 1] += a[i][0] - a[i - 1][0]
    s += a[i][1]
print(*res)


n = int(input())
points = set()
starts = {}
ends = {}

for i in range(n):
    a, b = map(int, input().split())
    points.add(a)
    points.add(b)
    starts[a] = 1 + starts.get(a, 0)
    ends[b] = 1 + ends.get(b, 0)

spoints = sorted(points)

dwd = {}

prev_point = spoints[0]
density = 0
for i, cur_point in enumerate(spoints):
    interval_length = cur_point - prev_point - 1
    if interval_length > 0:
        dwd[density] = interval_length + dwd.get(density, 0)

    starts_here = starts.get(cur_point, 0)
    density += starts_here

    dwd[density] = 1 + dwd.get(density, 0)

    ends_here = ends.get(cur_point, 0)
    density -= ends_here
    prev_point = cur_point

for i in range(1, n + 1):
    print(dwd.get(i, 0), end=' ')


n = int(input())
points = set()
starts = {}
ends = {}

for i in range(n):
    a, b = map(int, input().split())
    points.add(a)
    points.add(b)
    starts[a] = 1 + starts.get(a, 0)
    ends[b] = 1 + ends.get(b, 0)

spoints = sorted(points)

density_stats = {}

prev_point = spoints[0]
density = 0
for cur_point in spoints:
    interval_length = cur_point - prev_point - 1
    if interval_length > 0:
        density_stats[density] = interval_length + density_stats.get(density, 0)

    starts_here = starts.get(cur_point, 0)
    density += starts_here
    density_stats[density] = 1 + density_stats.get(density, 0)

    ends_here = ends.get(cur_point, 0)
    density -= ends_here
    prev_point = cur_point

for i in range(1, n + 1):
    print(density_stats.get(i, 0), end=' ')


import bisect

n = int(input())
lis = list()
idx = dict()
for i in range(n):
    l,r = map(int,input().split())
    idx[l]=1
    idx[r+1]=1
    lis.append([l,r])
val = [key for key,val in idx.items()]
val.sort()


cnt = [0]*((2*n)+1)
for item in lis:
    f1 = bisect.bisect_left(val,item[0])
    f2 = bisect.bisect_left(val,item[1]+1)
   
    cnt[f1]+=1
    cnt[f2]-=1

for i in range(1,2*n):
    cnt[i]+=cnt[i-1]


ans = [0]*(n+1)

for i in range(1,len(val)):
    sm = val[i]-val[i-1]

    ans[cnt[i-1]]+=sm

for i in range(1,n+1):
    print(ans[i],end=" ")
    
    

from collections import*
n=int(input())
d=defaultdict(int)
for _ in [0]*n:
 l,r=list(map(int,input().split()));d[l]+=1;d[r+1]-=1
s=p=0
f=[0]*(n+1)
for k,v in sorted(d.items()):
 f[s]+=k-p;s+=v;p=k
print(*f[1:])


from collections import*
n=int(input())
d=defaultdict(int)
for _ in [0]*n:
 l,r=map(int,input().split());d[l]+=1;d[r+1]-=1
s=p=0
f=[0]*(n+1)
for k in sorted(d):
 f[s]+=k-p;s+=d[k];p=k
print(*f[1:])

BEGIN = 'begin'
END = 'end'


def main():
    n = int(input())
    points = dict()

    for _ in range(n):
        li, ri = list(map(int, input().split()))

        update_point_status(points, li, BEGIN)
        update_point_status(points, ri, END)

    points = sorted(list(points.items()), key=lambda x: x[0])
    answer = [0] * (n + 1)

    start = -1
    count = 0
    for point in points:
        points_amount = point[0] - start - 1
        answer[count] += points_amount

        count += point[1][BEGIN]
        answer[count] += 1
        count -= point[1][END]

        start = point[0]

    print(' '.join(list(map(str, answer[1:]))))


def update_point_status(lines, point, status):
    if point not in lines:
        lines[point] = {BEGIN: 0, END: 0}

    lines[point][status] += 1


main()


import sys


class main:

    def __init__(self):
        self.n=int(sys.stdin.readline())

        self.line=dict()
        for i in range(self.n):
            a,b=(int(s) for s in sys.stdin.readline().rstrip().split(' '))
            self.line[a]=self.line.get(a,0)+1
            self.line[b+1]=self.line.get(b+1,0)-1

    def calc(self):
        self.result=dict()
        sorted_keys = sorted(self.line.keys())

        count=0
        last=sorted_keys[0]
        for k in sorted_keys:
            self.result[count]=self.result.get(count,0)+k-last
            count=count+self.line[k]
            last=k
        del self.result[0]

    def out(self):
        for k in range(1,self.n):
            print(self.result.get(k,0),end=' ')
        print(self.result.get(self.n, 0), end='')

    def solve(self):
        self.calc()
        self.out()


def __starting_point():
    m=main()
    m.solve()
    pass

__starting_point()

import sys

n = int(sys.stdin.readline())
start = dict()
end = dict()
for i in range(n):
    b, c = (int(s) for s in sys.stdin.readline().rstrip().split(' '))
    start[b] = start.setdefault(b, 0) + 1
    start.setdefault(c, 0)
    end[c] = end.setdefault(c, 0) + 1
    end.setdefault(b, 0)
keys = sorted(start.keys())
k = 0
a = [0 for x in range(n+1)]
prev = -1
start_c = 0
end_c = 0
for key in keys:
    if prev != -1 and key - prev > 1:
        a[start_c - end_c] += key - prev - 1
    start_c += start[key]
    a[start_c - end_c] += 1
    end_c += end[key]
    prev = key
print(' '.join(str(x) for x in a[1:n+1]))