#include <bits/stdc++.h>
using namespace std;
template <class T, class... S>
void dbs(string str, T t, S... s) {
  int idx = str.find(',');
  cout << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
int iter = 100;
using namespace std;
long double eps = 1e-9;
pair<long double, int> getT(vector<long double>& x, vector<long double>& v) {
  long double huh = 1e9, ind = -1;
  for (int i = 0; i < x.size() - 1; i++) {
    if (v[i] > v[i + 1] + eps) {
      if ((x[i + 1] - x[i]) / (v[i] - v[i + 1]) < huh) {
        huh = (x[i + 1] - x[i]) / (v[i] - v[i + 1]), ind = i;
      }
    }
  }
  return {huh, ind};
}
pair<long double, long double> getV(long double m1, long double v1,
                                    long double m2, long double v2) {
  long double vr1 = ((m1 - m2) * v1 + 2 * m2 * v2) / (m1 + m2);
  long double vr2 = ((m2 - m1) * v2 + 2 * m1 * v1) / (m1 + m2);
  return {vr1, vr2};
}
struct E {
  long double x, v, m;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  long double t;
  cin >> n >> t;
  vector<E> event(n);
  vector<long double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> event[i].x >> event[i].v >> event[i].m;
    p[i] = i;
  }
  sort(p.begin(), p.end(),
       [&](int i, int j) { return event[i].x < event[j].x; });
  vector<long double> v(n), x(n), m(n);
  for (int i = 0; i < n; i++) {
    v[i] = event[p[i]].v;
    x[i] = event[p[i]].x;
    m[i] = event[p[i]].m;
  }
  auto cur = getT(x, v);
  long double del = cur.first;
  while (cur.first < t && iter--) {
    for (int i = 0; i < n; i++) {
      x[i] += v[i] * (del);
    }
    sort(x.begin(), x.end());
    auto vv = getV(m[cur.second], v[cur.second], m[cur.second + 1],
                   v[cur.second + 1]);
    v[cur.second] = vv.first;
    v[cur.second + 1] = vv.second;
    auto y = getT(x, v);
    del = y.first;
    cur = {del + cur.first, y.second};
  }
  del -= cur.first - t;
  for (int i = 0; i < n; i++) {
    x[i] += v[i] * del;
  }
  vector<int> ip(n);
  for (int i = 0; i < n; i++) {
    ip[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cout << fixed << setprecision(8) << x[ip[i]] << '\n';
  }
  return 0;
}
