#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toll(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
double getV(double m1, double m2, double v1, double v2) {
  return (((m1 - m2) * v1) + 2 * m2 * v2) / (m1 + m2);
}
double getTimeOfIntersect(double v1, double v2, double dist, bool &can) {
  if (abs(v1 - v2) < 1e-9) {
    can = false;
    return 1e16;
  }
  double time = dist / (v2 - v1);
  if (time < 1e-9) {
    can = false;
    return 1e16;
  }
  can = true;
  return time;
}
struct ball {
  double x, m, v;
};
bool done[11];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<ball> v;
  int n;
  cin >> n;
  int t;
  cin >> t;
  for (int i = 0; i < n; i++) {
    ball b;
    cin >> b.x >> b.v >> b.m;
    v.push_back(b);
  }
  double elapsedTime = 0;
  while (1) {
    memset(done, 0, sizeof(done));
    double smallestCollide = 1e16;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double time = 0;
        bool can = false;
        time = getTimeOfIntersect(v[i].v, v[j].v, v[i].x - v[j].x, can);
        if (can) {
          smallestCollide = min(time, smallestCollide);
        }
      }
    }
    if (elapsedTime + smallestCollide > t + 1e-9) {
      smallestCollide = t - elapsedTime;
      for (int i = 0; i < n; i++) {
        v[i].x += +v[i].v * smallestCollide;
      }
      break;
    } else {
      elapsedTime += smallestCollide;
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          bool can;
          if (abs(smallestCollide -
                  getTimeOfIntersect(v[i].v, v[j].v, v[i].x - v[j].x, can)) <
              1e-9) {
            done[i] = done[j] = 1;
            v[i].x += v[i].v * smallestCollide;
            v[j].x += v[j].v * smallestCollide;
            double temp = v[i].v;
            v[i].v = getV(v[i].m, v[j].m, v[i].v, v[j].v);
            v[j].v = getV(v[j].m, v[i].m, v[j].v, temp);
          }
        }
      }
      for (int i = 0; i < n; i++) {
        if (!done[i]) {
          v[i].x += smallestCollide * v[i].v;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << setprecision(12) << v[i].x << endl;
  }
  return 0;
}
