#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
bool cmax(T &a, const U &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, class U>
bool cmin(T &a, const U &b) {
  return b < a ? a = b, 1 : 0;
}
void _BG(const char *s) { cerr << s << endl; }
template <class T, class... TT>
void _BG(const char *s, T a, TT... b) {
  for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
    c += count(begin("([{"), end("([{"), *s) -
         count(begin(")]}"), end(")]}"), *s);
  cerr << " = " << a;
  if (*s) {
    cerr << ", ";
    ++s;
  }
  _BG(s, b...);
}
struct pdd : pair<long long, long long> {
  using pair<long long, long long>::pair;
  pdd operator+(const pdd &p) const {
    return {first + p.first, second + p.second};
  }
  pdd operator-() const { return {-first, -second}; }
  pdd operator-(const pdd &p) const { return (*this) + (-p); }
  pdd operator*(long long f) const { return {f * first, f * second}; }
  long long operator*(const pdd &p) const {
    return first * p.first + second * p.second;
  }
};
double abs(const pdd &p) { return hypot(p.first, p.second); }
double arg(const pdd &p) { return atan2(p.second, p.first); }
long double cross(const pdd &p, const pdd &q) {
  const long double L = 1;
  return p.first * L * q.second - p.second * L * q.first;
}
long double cross(const pdd &p, const pdd &q, const pdd &o) {
  return cross(p - o, q - o);
}
pdd operator*(long long f, const pdd &p) { return p * f; }
vector<pdd> convex_hull(vector<pdd> pt) {
  sort(pt.begin(), pt.end());
  pt.resize(unique(begin(pt), end(pt)) - begin(pt));
  if (((int)(pt).size()) <= 2) return pt;
  int top = 0;
  vector<pdd> stk(2 * pt.size());
  for (int i = 0; i < (int)pt.size(); i++) {
    while (top >= 2 && cross(stk[top - 1], pt[i], stk[top - 2]) <= 0) top--;
    stk[top++] = pt[i];
  }
  for (int i = pt.size() - 2, t = top + 1; i >= 0; i--) {
    while (top >= t && cross(stk[top - 1], pt[i], stk[top - 2]) <= 0) top--;
    stk[top++] = pt[i];
  }
  stk.resize(top - 1);
  return stk;
}
vector<pdd> minkowski_bf(vector<pdd> a, vector<pdd> b) {
  vector<pdd> c;
  int n = a.size(), m = b.size();
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) c.push_back(a[i] + b[j]);
  return convex_hull(c);
}
vector<pdd> minkowski_csdn_1(vector<pdd> a, vector<pdd> b) {
  assert(((int)(a).size()) && ((int)(b).size()));
  a.push_back(a[0]);
  b.push_back(b[0]);
  int n = a.size(), m = b.size();
  vector<pdd> c = {a[0] + b[0]};
  int i = 1, j = 1;
  while (i < n && j < m) {
    ;
    if (cross(a[i] - a[i - 1], b[j] - b[j - 1]) < 0)
      c.push_back(c.back() + a[i] - a[i - 1]), ++i;
    else
      c.push_back(c.back() + b[j] - b[j - 1]), ++j;
  }
  while (i < n) c.push_back(c.back() + a[i] - a[i - 1]), ++i;
  while (j < m) c.push_back(c.back() + b[j] - b[j - 1]), ++j;
  return convex_hull(c);
}
vector<pdd> minkowski_itmo(vector<pdd> a, vector<pdd> b) {
  int n = a.size(), m = b.size(), i = 0, j = 0;
  a.push_back(a[0]);
  a.push_back(a[1]);
  b.push_back(b[0]);
  b.push_back(b[1]);
  vector<pdd> c;
  while (i < n || j < m) {
    c.push_back(a[i] + b[j]);
    int v = cross(a[i + 1] - a[i], b[j + 1] - b[j]);
    if (v < 0)
      ++i;
    else if (v > 0)
      ++j;
    else
      ++i, ++j;
  }
  return convex_hull(c);
}
vector<pdd> minkowski_csdn_2(vector<pdd> a, vector<pdd> b) {
  a.push_back(a[0]);
  b.push_back(b[0]);
  vector<pdd> q(((int)(a).size()) + ((int)(b).size()) + 5);
  int top = -1;
  q[++top] = a[0] + b[0];
  int i = 0, j = 0;
  while (i + 1 < a.size() && j + 1 < b.size()) {
    auto n1 = (a[i] + b[j + 1]) - q[top], n2 = (a[i + 1] + b[j]) - q[top];
    if (cross(n1, n2) < 0)
      q[++top] = a[i + 1] + b[j], i++;
    else
      q[++top] = a[i] + b[j + 1], j++;
  }
  for (; i < a.size(); i++) q[++top] = a[i] + b[b.size() - 1];
  for (; j < b.size(); j++) q[++top] = b[j] + a[a.size() - 1];
  q.resize(top + 1);
  return convex_hull(q);
}
vector<pdd> minkowski(vector<pdd> a, vector<pdd> b) {
  return minkowski_csdn_2(a, b);
}
const int N = 2e5 + 87;
vector<tuple<int, int, int>> E;
vector<int> g[N];
void add_edge(int u, int v, int a, int b) {
  g[u].push_back(((int)(E).size()));
  E.emplace_back(v, a, b);
  g[v].push_back(((int)(E).size()));
  E.emplace_back(u, a, b);
}
void build_binary_tree(int &n, int u = 1, int p = 0) {
  int pe = -1;
  for (int &i : g[u])
    if (get<0>(E[i]) == p) {
      pe = i;
      swap(i, g[u].back());
      g[u].pop_back();
      break;
    }
  for (int i : g[u]) build_binary_tree(n, get<0>(E[i]), u);
  while (g[u].size() > 2) {
    ++n;
    int i = g[u].back();
    g[u].pop_back();
    get<0>(E[i ^ 1]) = n;
    g[n].push_back(i);
    i = g[u].back();
    g[u].pop_back();
    get<0>(E[i ^ 1]) = n;
    g[n].push_back(i);
    add_edge(u, n, 0, 0);
  }
  if (pe != -1) g[u].push_back(pe);
}
int sz[N];
void getsz(int u, int p) {
  sz[u] = 1;
  for (int i : g[u])
    if (get<0>(E[i]) != p) {
      getsz(get<0>(E[i]), u);
      sz[u] += sz[get<0>(E[i])];
    }
}
pair<int, int> find_ct(int u, int p, int n) {
  pair<int, int> ct = {INT_MAX, -1};
  for (int i : g[u]) {
    int v = get<0>(E[i]);
    if (v == p) continue;
    ct = min(ct, find_ct(v, u, n));
    ct = min(ct, pair<int, int>(max(sz[v], n - sz[v]), i));
  }
  return ct;
}
void dfs(int u, int p, vector<pdd> &h, long long as = 0, long long bs = 0) {
  int ch = 0;
  for (int i : g[u])
    if (get<0>(E[i]) != p) {
      dfs(get<0>(E[i]), u, h, as + get<1>(E[i]), bs + get<2>(E[i]));
      ++ch;
    }
  if (ch == 0) h.emplace_back(as, bs);
}
vector<pdd> solve(int u0) {
  ;
  vector<pdd> ans, lh, rh;
  getsz(u0, 0);
  if (sz[u0] == 1) {
    ans.emplace_back(0, 0);
    return ans;
  }
  int ce = find_ct(u0, 0, sz[u0]).second;
  if (sz[u0] == 2) {
    ans.emplace_back(get<1>(E[ce]), get<2>(E[ce]));
    return ans;
  }
  int a = get<0>(E[ce]);
  int b = get<0>(E[ce ^ 1]);
  g[a].erase(find(begin(g[a]), end(g[a]), ce ^ 1));
  g[b].erase(find(begin(g[b]), end(g[b]), ce));
  ;
  dfs(a, 0, lh);
  for (auto &p : lh) {
    p.first += get<1>(E[ce]);
    p.second += get<2>(E[ce]);
  }
  lh = convex_hull(lh);
  dfs(b, 0, rh);
  rh = convex_hull(rh);
  ;
  ans = minkowski(lh, rh);
  ;
  for (const auto &p : solve(a)) ans.push_back(p);
  for (const auto &p : solve(b)) ans.push_back(p);
  return convex_hull(ans);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    add_edge(u, v, a, b);
  }
  build_binary_tree(n);
  auto a = solve(1);
  int t = a.size();
  for (int i = 0; i < m; ++i) {
    pdd p(i, 1);
    while (t >= 2 && a[t - 1] * p < a[t - 2] * p) --t;
    cout << a[t - 1] * p << " \n"[i == m - 1];
  }
}
