#include <bits/stdc++.h>
using namespace std;
struct ball {
  double x;
  double v;
  double m;
  double time;
  ball() {}
  ball(double x_, double v_, double m_, double t_)
      : x(x_), v(v_), m(m_), time(t_) {}
};
struct boom {
  int b1;
  int b2;
  double time;
  boom() {}
  boom(int b1_, int b2_, double time_) : b1(b1_), b2(b2_), time(time_) {}
};
int n;
double t;
double world_time = 0;
vector<ball> world;
stringstream dbg;
bool boom_was() {
  dbg << t << " WORLD TIME " << world_time << endl;
  vector<boom> booms(1, boom(-1, -1, t + 1));
  vector<vector<bool> > used(n, vector<bool>(n, false));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      ball b1 = world[i];
      ball b2 = world[j];
      if (b1.v == b2.v || b1.x == b2.x || (b2.x - b1.x) / (b1.v - b2.v) <= 0)
        continue;
      double boom_time = world_time + (b2.x - b1.x) / (b1.v - b2.v);
      if (!used[i][j] && boom_time <= t && boom_time <= booms[0].time) {
        used[i][j] = true;
        used[j][i] = true;
        if (boom_time < booms[0].time) booms.clear();
        booms.push_back(boom(i, j, boom_time));
        dbg << "BOOM " << i << " in " << b1.x << " and " << j << " in " << b2.x
            << " time " << boom_time << " local_time "
            << (b2.x - b1.x) / (b1.v - b2.v) << endl;
      }
    }
  if (booms[0].b1 < 0) return false;
  vector<bool> boomers(n, true);
  double l_boom_time = 0;
  for (int i = 0; i < booms.size(); i++) {
    boomers[booms[i].b1] = false;
    boomers[booms[i].b2] = false;
    dbg << "boom bitween " << booms[i].b1 << " and " << booms[i].b2
        << " at time " << booms[i].time << endl;
    l_boom_time = booms[i].time - world_time;
    ball b1 = world[booms[i].b1];
    ball b2 = world[booms[i].b2];
    world[booms[i].b1].v =
        ((b1.m - b2.m) * b1.v + 2 * b2.m * b2.v) / (b1.m + b2.m);
    world[booms[i].b2].v =
        ((b2.m - b1.m) * b2.v + 2 * b1.m * b1.v) / (b1.m + b2.m);
    world[booms[i].b1].x = world[booms[i].b2].x = b1.x + b1.v * l_boom_time;
  }
  for (int i = 0; i < n; i++)
    if (boomers[i]) world[i].x = world[i].x + world[i].v * l_boom_time;
  dbg << "WORLD STATE NOW:" << endl;
  for (int i = 0; i < n; i++)
    dbg << i + 1 << " x=" << world[i].x << ", v=" << world[i].v << endl;
  world_time = booms[0].time;
  return true;
}
int main() {
  cin >> n >> t;
  world = vector<ball>(n, ball(0, 0, 0, t));
  for (int i = 0; i < n; i++) cin >> world[i].x >> world[i].v >> world[i].m;
  while (boom_was()) {
  }
  for (int i = 0; i < n; i++)
    cout << (world[i].x + world[i].v * (t - world_time)) << endl;
  return 0;
}
