#include <bits/stdc++.h>
using namespace std;
const double INF = 1e8;
const double eps = 1e-8;
struct Item {
  int ith;
  double x, v, m;
  bool operator<(const Item &t) const { return x < t.x; }
};
bool cmp(const Item &a, const Item &b) { return a.ith < b.ith; }
int main() {
  int n, idx;
  Item it[10];
  double t, t1, t2;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    it[i].ith = i;
    cin >> it[i].x >> it[i].v >> it[i].m;
  }
  sort(it, it + n);
  t1 = 0, t2 = INF;
  while (1) {
    for (int i = 0; i < n - 1; i++)
      if (it[i].v - it[i + 1].v > 0 &&
          t2 > (it[i + 1].x - it[i].x) / (it[i].v - it[i + 1].v)) {
        idx = i;
        t2 = (it[i + 1].x - it[i].x) / (it[i].v - it[i + 1].v);
      }
    if (t1 + t2 > t) {
      for (int i = 0; i < n; i++) it[i].x += it[i].v * (t - t1);
      break;
    } else {
      for (int i = 0; i < n; i++) it[i].x += it[i].v * t2;
      double v1 = ((it[idx].m - it[idx + 1].m) * it[idx].v +
                   2 * it[idx + 1].m * it[idx + 1].v) /
                  (it[idx].m + it[idx + 1].m);
      double v2 = ((it[idx + 1].m - it[idx].m) * it[idx + 1].v +
                   2 * it[idx].m * it[idx].v) /
                  (it[idx].m + it[idx + 1].m);
      it[idx].v = v1;
      it[idx + 1].v = v2;
      t1 += t2;
      t2 = INF;
    }
  }
  sort(it, it + n, cmp);
  for (int i = 0; i < n; i++) printf("%.6f\n", it[i].x);
  return 0;
}
