[N, M] = list(map(int, input().split()))

a = [list(map(int, input().split())) for i in range(N)]

def v(x, s):

	return sum([x[i]*(1 - 2*((s & (1 << i)) >> i)) for i in range(3)])

print((0 if M == 0 else max([sum([v(a[j], s) for j in sorted([i for i in range(N)], key = lambda i : v(a[i], s))[-M:]]) for s in range(8)])))
[N, M] = list(map(int, input().split()))

a = eval('input().split(),'*N)

print((0 if M==0 else max([sum(sorted([sum([int(x[b])*(s>>b&1or-1)for b in range(3)]) for x in a])[-M:])for s in range(8)])))
[N, M] = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(N)]


def v(x, s):
    return sum([x[i] * (1 - 2 * ((s & (1 << i)) >> i)) for i in range(3)])


print(
    (
        0
        if M == 0
        else max(
            [
                sum(
                    [
                        v(a[j], s)
                        for j in sorted(
                            [i for i in range(N)], key=lambda i: v(a[i], s)
                        )[-M:]
                    ]
                )
                for s in range(8)
            ]
        )
    )
)

[N, M] = list(map(int, input().split()))
a = eval("input().split()," * N)
print(
    (
        0
        if M == 0
        else max(
            [
                sum(
                    sorted(
                        [
                            sum([int(x[b]) * (s >> b & 1 or -1) for b in range(3)])
                            for x in a
                        ]
                    )[-M:]
                )
                for s in range(8)
            ]
        )
    )
)

-a = [list(map(int, input().split())) for i in range(N)] - - -def v(x, s): -    return sum([x[i] * (1 - 2 * ((s & (1 << i)) >> i)) for i in range(3)]) - - +a = eval("input().split()," * N) -                    [ -                        v(a[j], s) -                        for j in sorted( -                            [i for i in range(N)], key=lambda i: v(a[i], s) -                        )[-M:] -                    ] +                    sorted( +                        [ +                            sum([int(x[b]) * (s >> b & 1 or -1) for b in range(3)]) +                            for x in a +                        ] +                    )[-M:]