#include <bits/stdc++.h>
using namespace std;
struct ball {
  double v, m, x, t;
  int idx;
};
bool cmp(const ball& lhs, const ball& rhs) { return lhs.x < rhs.x; }
ball balls[16];
double colL[16], colR[16];
double ans[16];
int main() {
  int N, T;
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> balls[i].x >> balls[i].v >> balls[i].m;
    balls[i].t = 0;
    balls[i].idx = i;
  }
  sort(balls, balls + N, cmp);
  colL[0] = colR[N - 1] = -1;
  for (int i = 1; i < N; i++) {
    double sep = abs(balls[i - 1].x - balls[i].x);
    double vel = balls[i - 1].v - balls[i].v;
    if (vel <= 0)
      colR[i - 1] = colL[i] = -1;
    else
      colR[i - 1] = colL[i] = sep / vel;
  }
  set<tuple<double, int, int> > s;
  for (int i = 1; i < N; i++) {
    if (colL[i] != -1) s.insert(make_tuple(colL[i], i - 1, i));
  }
  while (s.size() != 0) {
    auto it = s.begin();
    if (get<0>(*it) > T) break;
    int b1 = get<1>(*it), b2 = get<2>(*it);
    double nv1 = ((balls[b1].m - balls[b2].m) * balls[b1].v +
                  2 * balls[b2].m * balls[b2].v) /
                 (balls[b1].m + balls[b2].m);
    double nv2 = ((balls[b2].m - balls[b1].m) * balls[b2].v +
                  2 * balls[b1].m * balls[b1].v) /
                 (balls[b1].m + balls[b2].m);
    balls[b1].x += balls[b1].v * (get<0>(*it) - balls[b1].t);
    balls[b2].x += balls[b2].v * (get<0>(*it) - balls[b2].t);
    balls[b1].t = balls[b2].t = get<0>(*it);
    balls[b1].v = nv1;
    balls[b2].v = nv2;
    s.erase(it);
    colR[b1] = -1;
    colL[b2] = -1;
    if (b1 != 0) {
      if (colL[b1] != -1) s.erase(s.find(make_tuple(colL[b1], b1 - 1, b1)));
      double sep =
          abs(balls[b1 - 1].x +
              balls[b1 - 1].v * (balls[b1].t - balls[b1 - 1].t) - balls[b1].x);
      double vel = balls[b1 - 1].v - balls[b1].v;
      if (vel <= 0)
        colR[b1 - 1] = colL[b1] = -1;
      else {
        colR[b1 - 1] = colL[b1] = balls[b1].t + (sep / vel);
        s.insert(make_tuple(colL[b1], b1 - 1, b1));
      }
    }
    if (b2 != N - 1) {
      if (colR[b2] != -1) s.erase(s.find(make_tuple(colR[b2], b2, b2 + 1)));
      double sep =
          abs(balls[b2 + 1].x +
              balls[b2 + 1].v * (balls[b2].t - balls[b2 + 1].t) - balls[b2].x);
      double vel = balls[b2].v - balls[b2 + 1].v;
      if (vel <= 0)
        colR[b2] = colL[b2 + 1] = -1;
      else {
        colR[b2] = colL[b2 + 1] = balls[b2].t + (sep / vel);
        s.insert(make_tuple(colR[b2], b2, b2 + 1));
      }
    }
  }
  for (int i = 0; i < N; i++)
    ans[balls[i].idx] = balls[i].x + balls[i].v * (T - balls[i].t);
  for (int i = 0; i < N; i++) printf("%0.9lf\n", ans[i]);
  return 0;
}
