Участник:Anirogozina/I AM VERY BUSY

Материал из DISCOPAL
Перейти к: навигация, поиск
T = int(input())
outputs = []
for t in range(T):
    N = int(input())
    array = []
    for n in range(N):
        [m, p]= input().split(' ')
        array.append((int(m), int(p)))
    array.sort(key=lambda x: x[1])
    i = 0
    num = 0
    while i < N:
        prev_end = array[i][1]
        num +=1
        while i < N and array[i][0] < prev_end:
            i += 1
    outputs.append(num)
for out_ in outputs:
	print(out_)