/*
Optimal solution O(N log N)
*/
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
double allocation[maxn];
int a[maxn], b[maxn], d[maxn], N, B;
double inf = 1e12;
vector< pair<double, int> > orders;
void solve() {
double remain = B;
for (int i = 1; i <= N; i++) {
allocation[i] = a[i];
remain -= a[i];
}
set<int> activeIndices;
double totalWeight = 0, totalMinAllocation = 0;
for (int i = 0; i < 2 * N; i++) {
double currentRatio = orders[i].first, nextRatio = orders[i + 1].first;
int idx = abs(orders[i].second);
if (orders[i].second < 0) {
activeIndices.insert(idx);
totalWeight += d[idx];
totalMinAllocation += a[idx];
} else {
activeIndices.erase(idx);
allocation[idx] = b[idx];
remain -= (b[idx] - a[idx]);
totalWeight -= d[idx];
totalMinAllocation -= a[idx];
}
if (nextRatio >= inf || (remain + totalMinAllocation) <= nextRatio * totalWeight) {
double totalAmount = remain + totalMinAllocation;
for (auto& id : activeIndices) {
allocation[id] = totalAmount * d[id] / totalWeight;
}
return;
}
}
}
int main() {
scanf("%d %d", &N, &B);
for (int i = 1; i <= N; i++) {
scanf("%d %d %d", &a[i], &b[i], &d[i]);
orders.push_back(make_pair(1.0 * a[i] / d[i], -i));
orders.push_back(make_pair(1.0 * b[i] / d[i], i));
}
orders.push_back(make_pair(inf, 0));
sort(orders.begin(), orders.end());
solve();
for (int i = 1; i <= N; i++) {
printf("%.9f\n", allocation[i]);
}
return 0;
}
LyoKCU9wdGltYWwgc29sdXRpb24gTyhOIGxvZyBOKQoqLwoKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbWF4biAxMDAwMDUKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmRvdWJsZSBhbGxvY2F0aW9uW21heG5dOwppbnQgYVttYXhuXSwgYlttYXhuXSwgZFttYXhuXSwgTiwgQjsKCmRvdWJsZSBpbmYgPSAxZTEyOwoKdmVjdG9yPCBwYWlyPGRvdWJsZSwgaW50PiA+IG9yZGVyczsKCnZvaWQgc29sdmUoKSB7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