One remarkable day company "X" received *k* machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers, but that's another story.

The company has now *n* tasks, for each of them we know the start time of its execution *s*<sub class="lower-index">*i*</sub>, the duration of its execution *t*<sub class="lower-index">*i*</sub>, and the company profit from its completion *c*<sub class="lower-index">*i*</sub>. Any machine can perform any task, exactly one at a time. If a machine has started to perform the task, it is busy at all moments of time from *s*<sub class="lower-index">*i*</sub> to *s*<sub class="lower-index">*i*</sub> + *t*<sub class="lower-index">*i*</sub> - 1, inclusive, and it cannot switch to another task.

You are required to select a set of tasks which can be done with these *k* machines, and which will bring the maximum total profit.
The first line contains two integer numbers *n* and *k* (1 ≤ *n* ≤ 1000, 1 ≤ *k* ≤ 50) — the numbers of tasks and machines, correspondingly.

The next *n* lines contain space-separated groups of three integers *s*<sub class="lower-index">*i*</sub>, *t*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub> (1 ≤ *s*<sub class="lower-index">*i*</sub>, *t*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>, 1 ≤ *c*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>), *s*<sub class="lower-index">*i*</sub> is the time where they start executing the *i*-th task, *t*<sub class="lower-index">*i*</sub> is the duration of the *i*-th task and *c*<sub class="lower-index">*i*</sub> is the profit of its execution.
MAP = {}
SIZE = 200000
n, k = map(int, input().split())
timeBegin = [0] * 10000
timeEnd = [0] * 10000
ctask = [0] * 10000
a = [-1] * SIZE
v = [0] * SIZE
w = [0] * SIZE
c = [0] * SIZE
uk = [0] * SIZE
pr = [0] * SIZE
d = [2000000000] * SIZE
prEdge = [0] * SIZE
kolEdge = 0
ist = 0
st = 2 * n - 1
for i in range(n):
    timeBegin[i], timeEnd[i], ctask[i] = map(int, input().split())
    timeEnd[i] += timeBegin[i]
    MAP[timeBegin[i]] = 0
    MAP[timeEnd[i]] = 0
ind = 0
for key in sorted(MAP.keys()):
    MAP[key] = ind
    ind += 1
for i in range(n):
    timeBegin[i] = MAP[timeBegin[i]]
    timeEnd[i] = MAP[timeEnd[i]]
for i in range(2 * n):
    a[i] = -1
for i in range(n):
    v1, v2, c1, w1 = timeBegin[i], timeEnd[i], 1, -ctask[i]
    v[kolEdge] = v2
    w[kolEdge] = w1
    c[kolEdge] = c1
    uk[kolEdge] = a[v1]
    a[v1] = kolEdge
    kolEdge += 1
    v1, v2, c1, w1 = timeEnd[i], timeBegin[i], 0, ctask[i]
    v[kolEdge] = v2
    w[kolEdge] = w1
    c[kolEdge] = c1
    uk[kolEdge] = a[v1]
    a[v1] = kolEdge
    kolEdge += 1
for i in range(1, 2 * n):
    v1, v2, c1, w1 = i - 1, i, k, 0
    v[kolEdge] = v2
    w[kolEdge] = w1
    c[kolEdge] = c1
    uk[kolEdge] = a[v1]
    a[v1] = kolEdge
    kolEdge += 1
def fordFulkerson():
    for i in range(2 * n):
        d[i] = 2000000000
    d[0] = 0
    pr[0] = -1
    while True:
        wasRelax = False
        for i in range(2 * n):
            if d[i] < 2000000000:
                ind = a[i]
                while ind >= 0:
                    v1 = v[ind]
                    if c[ind] > 0 and d[v1] > d[i] + w[ind]:
                        d[v1] = d[i] + w[ind]
                        prEdge[v1] = ind
                        pr[v1] = i
                        wasRelax = True
                    ind = uk[ind]
        if not wasRelax:
            break
    if d[2 * n - 1] == 2000000000:
        return False
    v1 = 2 * n - 1
    while v1 > 0:
        ind = prEdge[v1]
        c[ind] -= 1
        c[ind ^ 1] += 1
        v1 = pr[v1]
    return True
for i in range(k):
    fordFulkerson()
for i in range(n):
    print(1 - c[i * 2], end=" ")
print()# 1693582931.283003