#include <bits/stdc++.h>
using namespace std;
bool feq(double a, double b) { return abs(a - b) < 1e-7; }
struct ball {
  double pos;
  double speed;
  double weight;
  double time;
  int name;
  bool operator<(const ball& comp) const { return pos < comp.pos; }
  bool operator>(const ball& comp) const { return pos > comp.pos; }
};
struct bounce {
  int b1, b2;
  double time;
  bool operator<(const bounce& comp) const { return time > comp.time; }
  bool operator>(const bounce& comp) const { return time < comp.time; }
};
int main() {
  int n, T;
  cin >> n >> T;
  vector<ball> balls(n);
  for (int i = 0; i < n; i++) {
    cin >> balls[i].pos >> balls[i].speed >> balls[i].weight;
    balls[i].time = 0;
    balls[i].name = i;
  }
  sort(balls.begin(), balls.end());
  priority_queue<bounce> pq;
  for (int i = 0; i < n - 1; i++) {
    bounce b;
    b.b1 = i;
    b.b2 = i + 1;
    double t;
    if (balls[i].speed == balls[i + 1].speed) continue;
    t = (balls[i].pos - balls[i + 1].pos) /
        (balls[i + 1].speed - balls[i].speed);
    if (t < 0) continue;
    b.time = t;
    pq.push(b);
  }
  vector<int> lastchoques;
  double lastt = 0;
  while (pq.empty() == false) {
    bounce current = pq.top();
    pq.pop();
    if (current.time >= T) break;
    if (current.time < lastt - 1e-7) continue;
    int i = current.b1;
    double realt;
    if (feq(balls[i].speed, balls[i + 1].speed)) continue;
    realt = (balls[i].pos - balls[i + 1].pos - balls[i].time * balls[i].speed +
             balls[i + 1].time * balls[i + 1].speed) /
            (balls[i + 1].speed - balls[i].speed);
    if (!feq(realt, current.time)) continue;
    if (feq(lastt, realt)) {
      bool cont = false;
      for (int j = 0; j < lastchoques.size(); j++) {
        if (lastchoques[j] == i) cont = true;
      }
      if (cont) continue;
    } else {
      lastchoques.clear();
    }
    lastt = realt;
    lastchoques.push_back(i);
    double newv1 = ((balls[i].weight - balls[i + 1].weight) * balls[i].speed +
                    2 * balls[i + 1].weight * balls[i + 1].speed) /
                   (balls[i + 1].weight + balls[i].weight);
    double newv2 =
        ((balls[i + 1].weight - balls[i].weight) * balls[i + 1].speed +
         2 * balls[i].weight * balls[i].speed) /
        (balls[i + 1].weight + balls[i].weight);
    double newx = balls[i].pos + balls[i].speed * (realt - balls[i].time);
    balls[i].pos = newx;
    balls[i].speed = newv1;
    balls[i].time = realt;
    balls[i + 1].pos = newx;
    balls[i + 1].speed = newv2;
    balls[i + 1].time = realt;
    if (i > 0) {
      if (!feq(balls[i].speed, balls[i - 1].speed)) {
        double t;
        t = (balls[i - 1].pos - balls[i].pos -
             balls[i - 1].time * balls[i - 1].speed +
             balls[i].time * balls[i].speed) /
            (balls[i].speed - balls[i - 1].speed);
        if (t > realt) {
          bounce b;
          b.b1 = i - 1;
          b.b2 = i;
          b.time = t;
          pq.push(b);
        }
      }
    }
    if (i + 2 < n) {
      if (!feq(balls[i + 1].speed, balls[i + 2].speed)) {
        double t;
        t = (balls[i + 1].pos - balls[i + 2].pos -
             balls[i + 1].time * balls[i + 1].speed +
             balls[i + 2].time * balls[i + 2].speed) /
            (balls[i + 2].speed - balls[i + 1].speed);
        if (t > realt) {
          bounce b;
          b.b1 = i + 1;
          b.b2 = i + 2;
          b.time = t;
          pq.push(b);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (balls[j].name == i) {
        double lastpos;
        lastpos = balls[j].pos + (T - balls[j].time) * balls[j].speed;
        printf("%0.9f\n", lastpos);
      }
    }
  }
}
