#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool MinPlace(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
struct ball {
  double x, v;
  int m, id;
  bool operator<(const ball &b) const { return x < b.x; }
  ball(double x, double v, int m, int id) : x(x), v(v), m(m), id(id){};
};
struct col {
  double t;
  int i, j;
  bool operator<(const col &b) const { return t > b.t; }
  bool operator==(const col &b) const {
    return t == b.t and i == b.i and j == b.j;
  }
  bool operator!=(const col &b) const { return !(this->operator==(b)); }
  col(double t, int i, int j) : t(t), i(i), j(j){};
};
vector<ball> balls;
priority_queue<col> cols;
col getCol(ball a, ball b) {
  if (a.x > b.x) return getCol(b, a);
  col ret(101.0, min(a.id, b.id), max(a.id, b.id));
  if (a.v - b.v > 0) ret.t = (b.x - a.x) / (a.v - b.v);
  return ret;
}
void collide(col c, int t) {
  if ((getCol(balls[c.i], balls[c.j]) != c) || (c.t > t)) return;
  ball &one = balls[c.i];
  ball &two = balls[c.j];
  double pos = one.x + c.t * one.v;
  double v1p = ((one.m - two.m) * one.v + 2 * two.m * two.v) / (one.m + two.m);
  double v2p = ((two.m - one.m) * two.v + 2 * one.m * one.v) / (one.m + two.m);
  one.v = v1p;
  two.v = v2p;
  one.x = pos - v1p * c.t;
  two.x = pos - v2p * c.t;
  col c1(0, 0, 0);
  for (int i = 0; i < balls.size(); i++) {
    if (i == c.i || i == c.j) continue;
    c1 = getCol(one, balls[i]);
    if (c1.t > c.t) cols.push(c1);
    c1 = getCol(two, balls[i]);
    if (c1.t > c.t) cols.push(c1);
  }
}
ostream &operator<<(ostream &out, const ball &b) {
  out << "[";
  out << "x : " << b.x << ", ";
  out << "v : " << b.v << ", ";
  out << "m : " << b.m << ", ";
  out << "id : " << b.id << " ]\n";
  return out;
}
ostream &operator<<(ostream &out, const col &c) {
  out << "[";
  out << "t : " << c.t << ", ";
  out << "i : " << c.i << ", ";
  out << "j : " << c.j << " ]\n";
  return out;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, t;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    double x, v;
    int m;
    cin >> x >> v >> m;
    balls.emplace_back(x, v, m, i);
    for (int j = 0; j < i; j++) cols.push(getCol(balls[i], balls[j]));
  }
  while (!cols.empty()) {
    col c1 = cols.top();
    collide(c1, t);
    cols.pop();
  }
  cout << setprecision(4) << fixed;
  for (int i = 0; i < n; i++) cout << (balls[i].x + balls[i].v * t) << "\n";
}
