#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Function {
int A, B, C;
int getValue(int x) {
return A * x * x + B * x + C;
}
};
bool compare(int a, int b)
{
return a < b;
}
int main() {
int n, m;
cin >> n >> m;
vector<Function> functions(n+1);
vector<int> functionValues;
for (int i = 0; i < n; i++) {
cin >> functions[i].A >> functions[i].B >> functions[i].C;
}
for (int i = 0; i < n; i++)
{
for (int x = 1; x <= m; x++)
{
functionValues.push_back(functions[i].getValue(x));
}
}
sort(functionValues.begin(), functionValues.end(), compare);
for (int i = 0; i < m; i++)
{
cout << functionValues[i] << " ";
}
cout << endl;
return 0;
}