N,C = list(map(int,input().split()))

ch = {}

for _ in range(N):

    s,t,c = list(map(int,input().split()))

    if c not in ch:

        ch[c] = [0 for _ in range(2*10**5+2)]

    for i in range(2*s-1,2*t):

        ch[c][i]=1

cmax = 0

for i in range(2*10**5+2):

    cnt = 0

    for c in ch:

        if ch[c][i]==1:

            cnt += 1

    cmax = max(cmax,cnt)

print(cmax)
N,C = list(map(int,input().split()))

G = {i:[0 for _ in range(10**5+1)] for i in range(1,C+1)}

for i in range(N):

    s,t,c = list(map(int,input().split()))

    G[c][s] += 1

    G[c][t] -= 1

F = [0 for _ in range(2*(10**5)+1)]

for c in range(1,C+1):

    for i in range(10**5+1):

        if G[c][i]==1:

            F[2*i-1] += 1

        elif G[c][i]==-1:

            F[2*i] -= 1

H = [0 for _ in range(2*(10**5)+1)]

for i in range(1,2*(10**5)+1):

    H[i] = H[i-1]+F[i]

print((max(H)))
N, C = list(map(int, input().split()))
ch = {}
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    if c not in ch:
        ch[c] = [0 for _ in range(2 * 10**5 + 2)]
    for i in range(2 * s - 1, 2 * t):
        ch[c][i] = 1
cmax = 0
for i in range(2 * 10**5 + 2):
    cnt = 0
    for c in ch:
        if ch[c][i] == 1:
            cnt += 1
    cmax = max(cmax, cnt)
print(cmax)

N, C = list(map(int, input().split()))
G = {i: [0 for _ in range(10**5 + 1)] for i in range(1, C + 1)}
for i in range(N):
    s, t, c = list(map(int, input().split()))
    G[c][s] += 1
    G[c][t] -= 1
F = [0 for _ in range(2 * (10**5) + 1)]
for c in range(1, C + 1):
    for i in range(10**5 + 1):
        if G[c][i] == 1:
            F[2 * i - 1] += 1
        elif G[c][i] == -1:
            F[2 * i] -= 1
H = [0 for _ in range(2 * (10**5) + 1)]
for i in range(1, 2 * (10**5) + 1):
    H[i] = H[i - 1] + F[i]
print((max(H)))

-ch = {} -for _ in range(N): +G = {i: [0 for _ in range(10**5 + 1)] for i in range(1, C + 1)} +for i in range(N): -    if c not in ch: -        ch[c] = [0 for _ in range(2 * 10**5 + 2)] -    for i in range(2 * s - 1, 2 * t): -        ch[c][i] = 1 -cmax = 0 -for i in range(2 * 10**5 + 2): -    cnt = 0 -    for c in ch: -        if ch[c][i] == 1: -            cnt += 1 -    cmax = max(cmax, cnt) -print(cmax) +    G[c][s] += 1 +    G[c][t] -= 1 +F = [0 for _ in range(2 * (10**5) + 1)] +for c in range(1, C + 1): +    for i in range(10**5 + 1): +        if G[c][i] == 1: +            F[2 * i - 1] += 1 +        elif G[c][i] == -1: +            F[2 * i] -= 1 +H = [0 for _ in range(2 * (10**5) + 1)] +for i in range(1, 2 * (10**5) + 1): +    H[i] = H[i - 1] + F[i] +print((max(H)))