#include<iostream>#include<queue>usingnamespacestd;
constint maxn = 1e4+5;
struct func{int a, b, c;}f[maxn];
struct var{int num,x,val;}res[maxn];
booloperator < (var a, var b){return a.val>b.val;}
priority_queue<var,vector<var>,less<var> >q;
int main(){
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; i++){
cin>>f[i].a>>f[i].b>>f[i].c;
q.push((var){i,1,f[i].a+f[i].b+f[i].c});
}
for(int i = 1; i <= m; i++){
var t = q.top(); q.pop();
cout<<t.val<<' ';
q.push(var{t.num,t.x+1,f[t.num].a*(t.x+1)*(t.x+1)+f[t.num].b*(t.x+1)+f[t.num].c});
}
return0;
}