#include <bits/stdc++.h>
using namespace std;
int const MAXN = 1000;
double const eps = 1e-8;
int n;
double t, ans[MAXN];
struct elem {
  double x, v, m;
  int num;
} s[MAXN];
void change_all(double add_time) {
  for (int i = 0; i < n; i++) s[i].x += s[i].v * add_time;
}
int r_eq(double a, double b) { return fabs(a - b) <= eps; }
int r_le(double a, double b) { return b - a >= eps || fabs(a - b) <= eps; }
int r_me(double a, double b) { return a - b >= eps || fabs(a - b) <= eps; }
int r_m(double a, double b) { return a - b >= eps; }
int stolk(double v1, double v2) { return r_m(v1, v2); }
bool operator<(const elem &a, const elem &b) { return a.x < b.x; }
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> s[i].x >> s[i].v >> s[i].m;
    s[i].num = i;
  }
  double cur_time = 0;
  sort(s, s + n);
  while (1) {
    double mn = 1e100;
    for (int i = 0; i < n - 1; i++) {
      int j = i + 1;
      if (stolk(s[i].v, s[j].v)) {
        double dst = fabs(s[i].x - s[j].x);
        double tm;
        tm = dst / (s[i].v - s[j].v);
        tm = fabs(tm);
        if (tm < mn) mn = tm;
      }
    }
    if (cur_time + mn > t) break;
    change_all(mn);
    cur_time += mn;
    for (int i = 0; i < n - 1; i++)
      if (r_eq(s[i].x, s[i + 1].x)) {
        int a = i;
        int b = i + 1;
        double v1 = s[a].v;
        double m1 = s[a].m;
        double v2 = s[b].v;
        double m2 = s[b].m;
        double new_v1 = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
        double new_v2 = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
        s[a].v = new_v1;
        s[b].v = new_v2;
      }
  }
  change_all(t - cur_time);
  for (int i = 0; i < n; i++) ans[s[i].num] = s[i].x;
  for (int i = 0; i < n; i++) printf("%.8lf\n", ans[i]);
  return 0;
}
