#include<bits/stdc++.h>

using namespace std;

const int maxN = 1000009;
int N, X, b[maxN], p[maxN], l[maxN], r[maxN];
/*int lg, N, X, aib[2 * maxN], val[2 * maxN];
long long aibSum[2 * maxN], ans = 1LL << 60;
pair < int, int > h[2 * maxN];
pair < int, pair < int, int > > v[maxN];

set < int > S;
void able (int pos, int x)
{
    ///val = +-1 (aka enable or disable)
    if (x < 0) S.erase (pos);
    else S.insert (pos);
    int y = val[pos] * x;
    while (pos <= 2 * N)
        aibSum[pos] += y,
        aib[pos] += x,
        pos += pos - (pos & (pos - 1));
}

void attempt (long long need)
{
    ///max aibSum * X < need
    int pos = 0, used = 0;
    for (int i=lg; i>=0; i--)
        if (pos + (1 << i) <= 2 * N && 1LL * X * aibSum[pos + (1 << i)] < need)
            pos |= 1 << i, need -= 1LL * X * aibSum[pos], used += aib[pos];
    for (auto it : S)
        printf ("%d ", it);
    printf ("? >= %d\n", pos);
    auto it = S.lower_bound (pos + 1);
    assert (it != S.end ());
    int leftover = (need + val[*it] - 1) / val[*it];
    long long curr = 1LL * X * used + leftover;
    if (curr < ans)
        ans = curr;
}*/

long long f (int i)
{
    return 1LL * (X - b[i]) * r[i] + 1LL * b[i] * l[i];
}

bool cmp (int i, int j)
{
    return f (i) > f (j);
}

bool ok (long long moves)
{
    int cnt = moves / X, smth = moves % X;
    long long toOvercome = 0;
    for (int i=1; i<=N; i++)
        toOvercome += 1LL * l[i] * b[i];
    long long firstCntSum = 0;
    for (int i=1; i<=cnt; i++)
        firstCntSum += f(p[i]);
    for (int i=1; i<=N; i++)
    {
        ///assume i is smth
        long long curr = toOvercome;
        int pos = p[i];
        if (b[pos] >= smth) curr -= 1LL * smth * l[pos];///unimportant
        else curr += 1LL * b[pos] * (r[pos] - l[pos]), curr -= (1LL * smth * r[pos]);
        curr -= firstCntSum;
        if (i <= cnt)
            curr -= f (p[cnt + 1]) - f (pos); ///this should've been in firstCntSum
        if (curr <= 0)
            return 1;
    }
    return 0;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &X);
/*for (int i=1; i<=N; i++)
    scanf ("%d %d %d", &v[i].first, &v[i].second.first, &v[i].second.second);
sort (v + 1, v + N + 1, cmp);
for (int i=1; i<=N; i++)
    h[2 * i - 1] = {-v[i].second.first, i},
    h[2 * i] = {-v[i].second.second, -i};
sort (h + 1, h + 2 * N + 1);
for (int i=1; i<=2 * N; i++)
{
    val[i] = -h[i].first;
    if (h[i].second > 0) v[h[i].second].second.first = i;
    else v[-h[i].second].second.second = i;
}
lg = 0;
while ((2 << lg) <= 2 * N)
    lg ++;
long long opponentValue = 0;
for (int i=1; i<=N; i++)
    opponentValue += 1LL * v[i].first * val[v[i].second.first],
    able (v[i].second.first, +1); ///all unimportant
attempt (opponentValue);
for (int i=1; i<=N; i++)
    opponentValue += 1LL * v[i].first * (val[v[i].second.second] - val[v[i].second.first]),
    able (v[i].second.first, -1),
    able (v[i].second.second, +1),
    attempt (opponentValue);
printf ("%lld\n", ans);*/
for (int i=1; i<=N; i++)
    scanf ("%d %d %d", &b[i], &l[i], &r[i]), p[i] = i;
sort (p + 1, p + N + 1, cmp);
{
    long long p = 0, u = 1LL * N * X - 1, mid, ras = 1LL * N * X;
    while (p <= u)
    {
        mid = (p + u) >> 1;
        if (ok (mid))
            ras = mid, u = mid - 1;
        else p = mid + 1;
    }
    printf ("%lld\n", ras);
}
return 0;
}

#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;
typedef pair<Point, double> Circle;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }

    bool cmp_y(const Point &a, const Point &b) {
        return !equals(a.Y, b.Y) ? a.Y < b.Y : a.X < b.X;
    }
}

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon convexHull(Polygon ps){
    int n = ps.size();
    sort(ps.begin(), ps.end(), cmp_y);
    int k = 0;
    Polygon convex(n * 2);
    for(int i=0; i<n; i++){
        while(k >= 2 && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    for(int i=n-2, t=k; i>=0; i--){
        while(k > t && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    convex.resize(k-1);
    return convex;
}

double arg(Vector p){
    return atan2(p.Y, p.X);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    Polygon pol;
    vector<double> x(n), y(n);
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i];
        pol.emplace_back(x[i], y[i]);
    }

    pol = convexHull(pol);

    int m = pol.size();

    map<pair<double, double>, double> ans;
    for(int i=0; i<m; i++){
        Vector A = pol[(i+1)%m] - pol[i];
        Vector B = pol[(i-1+m)%m] - pol[i];
        Vector C = pol[(i+1)%m] - pol[(i-1+m)%m];

        double cos_i = (abs(A) * abs(A) + abs(B) * abs(B) - abs(C) * abs(C)) / (2 * abs(A) * abs(B));
        double theta = acos(cos_i);
        theta = pi - theta;
        double alpha = theta / 2 / pi;
        ans[make_pair(pol[i].X, pol[i].Y)] = alpha;
    }

    for(int i=0; i<n; i++){
        printf("%.8f\n", ans[make_pair(x[i], y[i])]);
    }
}