for i in range(int(input())):
    l = []
    n = int(input())
    a, b = map(int, input().split())
    e = 1
    for j in range(1, n):
        c, d = map(int, input().split())
        if c in range(a, b):
            b = c
            a = d
        else:
            e = e + 1
            b = c
            a = d
    print(e)

cd71e3df44d0972a9b5ff94ece5ce79225434002
<mask token>

for i in range(int(input())):
    l = []
    n = int(input())
    a, b = map(int, input().split())
    e = 1
    for j in range(1, n):
        c, d = map(int, input().split())
        if c in range(a, b):
            b = c
            a = d
        else:
            e = e + 1
            b = c
            a = d
    print(e)
