n,m=list(map(int,input().split()))

ass=[tuple(map(int,input().split())) for i in range(m)]

ass.sort(key=lambda x:x[1])



acum = []



def ifsatisfied(ab):

    for x in acum:

        if ab[0]<x <=ab[1]:

            return(True)

    return(False)



for ab in ass:

    if not ifsatisfied(ab):

        acum.append(ab[1])



print((len(acum)))

n,m=list(map(int,input().split()))

ass=[tuple(map(int,input().split())) for i in range(m)]

ass.sort(key=lambda x:x[1])



acum = []



def ifsatisfied(ab):

    for x in acum:

        if ab[0]<x <=ab[1]:

            return(True)

    return(False)



for ab in ass:

    if (acum == [] or ab[0]>=acum[-1]):

        acum.append(ab[1])



print((len(acum)))

n, m = list(map(int, input().split()))
ass = [tuple(map(int, input().split())) for i in range(m)]
ass.sort(key=lambda x: x[1])
acum = []


def ifsatisfied(ab):
    for x in acum:
        if ab[0] < x <= ab[1]:
            return True
    return False


for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])
print((len(acum)))

n, m = list(map(int, input().split()))
ass = [tuple(map(int, input().split())) for i in range(m)]
ass.sort(key=lambda x: x[1])
acum = []


def ifsatisfied(ab):
    for x in acum:
        if ab[0] < x <= ab[1]:
            return True
    return False


for ab in ass:
    if acum == [] or ab[0] >= acum[-1]:
        acum.append(ab[1])
print((len(acum)))

-    if not ifsatisfied(ab): +    if acum == [] or ab[0] >= acum[-1]: