#include <bits/stdc++.h>
using namespace std;
const int MAXN = 12;
const double EPS = 1e-8;
const double INF = 1e30;
int n;
double t, x[MAXN], v[MAXN], m[MAXN];
double dt, nowt;
inline double Zero(double x) { return fabs(x) < EPS; }
void init() {
  scanf("%d%lf", &n, &t);
  for (int i = 0; i < n; ++i) scanf("%lf%lf%lf", &x[i], &v[i], &m[i]);
}
void solve() {
  nowt = 0;
  while (1) {
    double dt = INF;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        if (!Zero(v[i] - v[j])) {
          double tem = (x[i] - x[j]) / (v[j] - v[i]);
          if (tem > EPS && tem < dt) dt = tem;
        }
    if (nowt + dt - t > EPS) {
      dt = t - nowt;
      for (int i = 0; i < n; ++i) x[i] += v[i] * dt;
      break;
    }
    for (int i = 0; i < n; ++i) x[i] += v[i] * dt;
    nowt += dt;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        if (Zero(x[i] - x[j])) {
          int a = i, b = j;
          double va = v[a], vb = v[b];
          v[a] = ((m[a] - m[b]) * va + 2 * m[b] * vb) / (m[a] + m[b]);
          v[b] = ((m[b] - m[a]) * vb + 2 * m[a] * va) / (m[a] + m[b]);
        }
  }
  for (int i = 0; i < n; ++i) printf("%.4f\n", x[i]);
}
int main() {
  init();
  solve();
  return 0;
}
