#include <bits/stdc++.h>
#pragma optimize GCC("O3")
using namespace std;
const long double EPS = 1e-7;
class ball {
 public:
  long double v, m, x;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  long double t;
  cin >> n >> t;
  vector<ball> v(n);
  for (int i = 0; i < n; i++) cin >> v[i].x >> v[i].v >> v[i].m;
  long double curr = 0.0;
  while ((t - curr) > EPS) {
    long double dt = t - curr;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (abs(v[j].x - v[i].x) < EPS || abs(v[j].v - v[i].v) < EPS) continue;
        dt = min(dt, abs((v[j].x - v[i].x) / (v[i].v - v[j].v)));
      }
    }
    for (int i = 0; i < n; i++) {
      v[i].x += v[i].v * dt;
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (abs(v[i].x - v[j].x) < EPS) {
          long double vi = v[i].v;
          long double vj = v[j].v;
          v[i].v =
              ((v[i].m - v[j].m) * vi + 2.0 * v[j].m * vj) / (v[i].m + v[j].m);
          v[j].v =
              ((v[j].m - v[i].m) * vj + 2.0 * v[i].m * vi) / (v[i].m + v[j].m);
        }
      }
    }
    curr += dt;
  }
  for (int i = 0; i < n; i++) {
    cout << setprecision(10) << fixed << v[i].x << endl;
  }
  return 0;
}
