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.
from math import sqrt
n,m = map(int,input().split())

def dist(x1,y1,x2,y2):
    d = (x1-x2)**2 + (y2-y1)**2
    if sqrt(d)!=int(sqrt(d)):
        return True
    else:
        return False

z = min(n,m)

print(z+1)

ans = []
ba = []
if n !=m :
 for i in range(z+1):
  if i!=0:
    ans.append([i,i])
else:
    ans.append([z,0])

for i in range(n+1):
    for j in range(m+1):
        if i!=0 or j!=0:
          ba.append([i,j])
if m!=n:
 for i in ba:
    x,y = i
    flag = 0
    for j in ans:
        a,b = j
        z = dist(x,y,a,b)
        if z == False:

            flag = 1
            break
    if flag == 0 :
        ans.append(i)
        break
else:
    for i in ba:
       x,y = i
       flag = 0
       for j in ans:
        a,b = j
        z = dist(x,y,a,b)
        if z == False:

            flag = 1
            break
       if flag == 0 :
          ans.append(i)


for i in ans:
    print(i[0],i[1])


