#include <bits/stdc++.h>
using namespace std;
struct Node {
  double x;
  double v;
  int m;
  int idx;
};
bool nodeCmp(const struct Node &n1, const struct Node &n2) {
  return n1.x <= n2.x;
}
bool nodeCmp2(const struct Node &n1, const struct Node &n2) {
  return n1.idx <= n2.idx;
}
void calcV(Node &n1, Node &n2, double &nv1, double &nv2) {
  nv1 = ((n1.m - n2.m) * n1.v + 2 * n2.m * n2.v) / (n1.m + n2.m);
  nv2 = ((n2.m - n1.m) * n2.v + 2 * n1.m * n1.v) / (n1.m + n2.m);
}
bool collide(Node &n1, Node &n2, double &t, double &nv1, double &nv2) {
  double v = n1.v - n2.v;
  if (v <= 0) return false;
  t = (n2.x - n1.x) / v;
  if (t <= 1e-9) return false;
  nv1 = ((n1.m - n2.m) * n1.v + 2 * n2.m * n2.v) / (n1.m + n2.m);
  nv2 = ((n2.m - n1.m) * n2.v + 2 * n1.m * n1.v) / (n1.m + n2.m);
  return true;
}
int main(void) {
  int n, t;
  cin >> n >> t;
  vector<Node> nodes(n);
  int i, j;
  for (i = 0; i < n; ++i) {
    cin >> nodes[i].x >> nodes[i].v >> nodes[i].m;
    nodes[i].idx = i;
  }
  double cur = 0;
  while (1) {
    stable_sort(nodes.begin(), nodes.end(), nodeCmp);
    double minCollideTime = t + 1;
    vector<int> poses;
    for (i = 0; i < n - 1; ++i) {
      double collideTime;
      double v1, v2;
      bool ret = collide(nodes[i], nodes[i + 1], collideTime, v1, v2);
      if (ret) {
        if (collideTime + 1e-9 <= minCollideTime) {
          minCollideTime = collideTime;
          poses.clear();
          poses.push_back(i);
        } else if (collideTime > minCollideTime - 1e-9 &&
                   collideTime < minCollideTime + 1e-9) {
          poses.push_back(i);
        }
      }
    }
    if (poses.size() == 0) break;
    if (cur + minCollideTime > t) break;
    for (i = 0; i < n; ++i) {
      nodes[i].x += nodes[i].v * minCollideTime;
    }
    for (i = 0; i < poses.size(); ++i) {
      int j = poses[i];
      double v1, v2;
      calcV(nodes[j], nodes[j + 1], v1, v2);
      nodes[j].v = v1;
      nodes[j + 1].v = v2;
    }
    double aa = 1e-10;
    for (i = 0; i < n; ++i) {
      nodes[i].x += nodes[i].v * aa;
    }
    cur += minCollideTime + aa;
  }
  double rem = t - cur;
  sort(nodes.begin(), nodes.end(), nodeCmp2);
  for (i = 0; i < n; ++i) {
    printf("%.9f\n", nodes[i].x + rem * nodes[i].v);
  }
  return 0;
}
