#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int N, T, Pid[12];
double X[12], V[12], M[12], Ret[12];
inline double Calc(int i, int j) {
  if (V[i] <= V[j]) return 1e99;
  return (X[i] - X[j]) / (V[j] - V[i]);
}
int main() {
  scanf("%d%d", &N, &T);
  for (int i = 0; i < N; i++) {
    scanf("%lf%lf%lf", &X[i], &V[i], &M[i]);
    Pid[i] = i;
  }
  double Now = 0;
  for (; Now <= T;) {
    double minT = T - Now;
    int P = -1, Q = -1;
    for (int i = 0; i < N; i++)
      for (int j = i + 1; j < N; j++)
        if (X[i] > X[j]) {
          swap(X[i], X[j]);
          swap(V[i], V[j]);
          swap(M[i], M[j]);
          swap(Pid[i], Pid[j]);
        }
    for (int i = 1; i < N; i++) {
      double TT = Calc(i - 1, i);
      if (TT < minT) {
        minT = TT;
        P = i - 1;
        Q = i;
      }
    }
    if (P == -1) break;
    Now += minT;
    for (int i = 0; i < N; i++) X[i] += minT * V[i];
    double V1 = ((M[P] - M[Q]) * V[P] + 2 * M[Q] * V[Q]) / (M[P] + M[Q]);
    double V2 = ((M[Q] - M[P]) * V[Q] + 2 * M[P] * V[P]) / (M[P] + M[Q]);
    V[P] = V1;
    V[Q] = V2;
  }
  for (int i = 0; i < N; i++) X[i] += V[i] * (T - Now);
  for (int i = 0; i < N; i++) Ret[Pid[i]] = X[i];
  for (int i = 0; i < N; i++) printf("%.6lf\n", Ret[i]);
  return 0;
}
