#include <bits/stdc++.h>
using namespace std;
long long vs[300000], b[300000], ok[300000];
vector<pair<int, int> > v;
class obj {
 public:
  double x, v, m;
  void input() { cin >> x >> v >> m; }
};
int main() {
  ios_base::sync_with_stdio(false);
  double n, m, k = 1, t, l = 0, th, h = 0, tt = 0, v1, v2;
  int i, j, ix1 = 0, ix2 = 0;
  obj a[30];
  cin >> n >> t;
  for (i = 1; i <= n; i++) a[i].input();
  while (1) {
    l = INT_MAX;
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++)
        if (a[i].v != a[j].v) {
          h = (a[j].x - a[i].x) / (a[i].v - a[j].v);
          if (h < l && h > 0) l = h;
        }
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++)
        if (a[i].v != a[j].v) {
          h = (a[j].x - a[i].x) / (a[i].v - a[j].v);
          if (abs(h - l) < 1e-9) v.push_back({i, j});
        }
    if (tt + l >= t) {
      l = t - tt;
      break;
    }
    for (i = 1; i <= n; i++) {
      a[i].x = a[i].x + a[i].v * l;
    }
    for (k = 0; k < v.size(); k++) {
      i = v[k].first;
      j = v[k].second;
      v1 = ((a[i].m - a[j].m) * a[i].v + 2 * a[j].m * a[j].v) /
           (a[i].m + a[j].m);
      v2 = a[i].v + v1 - a[j].v;
      a[i].v = v1;
      a[j].v = v2;
    }
    v.clear();
    tt += l;
  }
  for (i = 1; i <= n; i++) {
    a[i].x = a[i].x + a[i].v * l;
  }
  for (i = 1; i <= n; i++) cout << fixed << setprecision(12) << a[i].x << endl;
  return 0;
}
