#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long n,m,a[N],cnt = 1;
int main()
{
freopen("minval.in","r",stdin);
freopen("minval.out","w",stdout);
cin >> n >> m;
for (int i = 1,x,y,z;i <= n;i++)
{
cnt = (cnt > m + 1 ? m + 1 : cnt);
cin >> x >> y >> z;
int s = 1;
while (a[m] > s * s * x + s * y + z || cnt <= m)
{
a[cnt] = s * s * x + s * y + z;
cnt++;
s++;
}
sort (a + 1,a + cnt);
}
for (int i = 1;i <= m;i++)
{
cout << a[i] << " ";
}
return 0;
}