#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
T _max(T x, T y) {
  return x > y ? x : y;
}
template <class T>
T _min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T _abs(T x) {
  return (x < 0) ? -x : x;
}
template <class T>
T _mod(T x, T y) {
  return (x > 0) ? x % y : ((x % y) + y) % y;
}
template <class T>
void _swap(T& x, T& y) {
  T t = x;
  x = y;
  y = t;
}
template <class T>
void getmax(T& x, T y) {
  x = (y > x) ? y : x;
}
template <class T>
void getmin(T& x, T y) {
  x = (x < 0 || y < x) ? y : x;
}
int TS, cas = 1;
const int M = 10 + 5;
int n;
double t;
struct ball {
  double x, v, m;
  ball() {}
  ball(double _x, double _v, double _m) { x = _x, v = _v, m = _m; }
  void read() { scanf("%lf%lf%lf", &x, &v, &m); }
} p[M];
bool vis[M];
void collisions(int i, int j) {
  double v1 =
      ((p[i].m - p[j].m) * p[i].v + 2.0 * p[j].m * p[j].v) / (p[i].m + p[j].m);
  double v2 =
      ((p[j].m - p[i].m) * p[j].v + 2.0 * p[i].m * p[i].v) / (p[i].m + p[j].m);
  p[i].v = v1, p[j].v = v2;
}
void run() {
  int i, j;
  for (i = 1; i <= n; i++) p[i].read();
  double now = 0;
  memset(vis, 0, sizeof(vis));
  while (t > now && fabs(now - t) > (1e-8)) {
    double mint = 10000.0, tmp;
    int b1 = -1, b2 = -1;
    for (i = 1; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        if (fabs(p[i].v - p[j].v) <= (1e-8)) continue;
        tmp = (p[i].x - p[j].x) / (p[j].v - p[i].v);
        if (tmp < 0) continue;
        if (fabs(tmp) <= (1e-8)) {
          if (!vis[i]) collisions(i, j);
          continue;
        }
        if (mint > tmp) mint = tmp, b1 = i, b2 = j;
      }
    }
    if (b1 == -1 || now + mint > t) break;
    now += mint;
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; i++)
      if (!vis[i]) {
        for (j = i + 1; j <= n; j++)
          if (!vis[j]) {
            if (fabs(p[i].v - p[j].v) <= (1e-8)) continue;
            tmp = (p[i].x - p[j].x) / (p[j].v - p[i].v);
            if (tmp < 0) continue;
            if (fabs(tmp - mint) <= (1e-8)) {
              vis[i] = vis[j] = 1;
              p[i].x += p[i].v * mint, p[j].x += p[j].v * mint;
              collisions(i, j);
            }
          }
      }
    for (i = 1; i <= n; i++)
      if (!vis[i]) p[i].x += p[i].v * mint;
  }
  for (i = 1; i <= n; i++) printf("%.9lf\n", p[i].x + p[i].v * (t - now));
}
void preSof() {}
int main() {
  preSof();
  while ((~scanf("%d%lf", &n, &t))) run();
  return 0;
}
