#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const long long inf64 = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
class ball {
 public:
  long double x, v, m, i;
};
vector<ball> v;
int n, T;
void Load() {
  cin >> n >> T;
  ball cur;
  for (int i = 0; i < n; i++) {
    cin >> cur.x >> cur.v >> cur.m;
    cur.i = i;
    v.push_back(cur);
  }
}
bool operator<(const ball &a, const ball &b) {
  return a.x < b.x - 1e-9 || (fabs(a.x - b.x) < 1e-9 && a.v < b.v - 1e-9);
}
void Solve() {
  cerr.setf(ios::fixed | ios::showpoint);
  cerr.precision(10);
  long double t, nxt_t, cur_t;
  t = 0;
  sort(v.begin(), v.end());
  while (true) {
    nxt_t = inf;
    for (int i = 0; i < n - 1; i++) {
      if (fabs(v[i].v - v[i + 1].v) < 1e-9) continue;
      cur_t = (v[i + 1].x - v[i].x) / (v[i].v - v[i + 1].v);
      if (cur_t < 1e-9) continue;
      nxt_t = min(nxt_t, cur_t);
    }
    if (t + nxt_t > T + 1e-9) {
      for (int i = 0; i < n; i++) v[i].x = v[i].x + v[i].v * (T - t);
      break;
    }
    t = t + nxt_t;
    for (int i = 0; i < n; i++) v[i].x = v[i].x + v[i].v * nxt_t;
    for (int i = 0; i < n - 1; i++)
      if (fabs(v[i].x - v[i + 1].x) < 1e-9) {
        long double v1, v2;
        v1 = ((v[i].m - v[i + 1].m) * v[i].v + 2 * v[i + 1].m * v[i + 1].v) /
             (v[i].m + v[i + 1].m);
        v2 = ((v[i + 1].m - v[i].m) * v[i + 1].v + 2 * v[i].m * v[i].v) /
             (v[i].m + v[i + 1].m);
        v[i].v = v1;
        v[i + 1].v = v2;
      }
    sort(v.begin(), v.end());
  }
  cout.setf(ios::fixed | ios::showpoint);
  cout.precision(10);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (v[j].i == i) cout << v[j].x << "\n";
}
int main() {
  Load();
  Solve();
  return 0;
}
