#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int dblcmp(double d) {
  if (fabs(d) < eps) return 0;
  return d > eps ? 1 : -1;
}
double x[111], v[111], m[111], t;
int n;
int main() {
  int i, j, k;
  scanf("%d%lf", &n, &t);
  for (i = 0; i < n; i++) scanf("%lf%lf%lf", x + i, v + i, m + i);
  while (dblcmp(t) > 0) {
    double mt = 1e100;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) continue;
        if (dblcmp(x[i] - x[j]) < 0 && dblcmp(v[i] - v[j]) > 0) {
          double nt = fabs(x[i] - x[j]) / (v[i] - v[j]);
          mt = min(mt, nt);
        }
      }
    }
    if (dblcmp(mt - t) > 0) {
      for (i = 0; i < n; i++) {
        x[i] += v[i] * t;
      }
      t = 0;
      continue;
    }
    vector<int> p1, p2;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) continue;
        if (dblcmp(x[i] - x[j]) < 0 && dblcmp(v[i] - v[j]) > 0) {
          double nt = fabs(x[i] - x[j]) / (v[i] - v[j]);
          if (dblcmp(nt - mt) == 0) {
            p1.push_back(i);
            p2.push_back(j);
          }
        }
      }
    }
    for (i = 0; i < n; i++) {
      x[i] += v[i] * mt;
    }
    for (int xx = 0; xx < (int)((p1).size()); xx++) {
      i = p1[xx];
      j = p2[xx];
      double m1, m2, v1, v2;
      m1 = m[i];
      m2 = m[j];
      v1 = v[i];
      v2 = v[j];
      v[i] = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
      v[j] = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
    }
    t -= mt;
  }
  for (i = 0; i < n; i++) {
    printf("%.12lf\n", x[i]);
  }
  return 0;
}
