#include <bits/stdc++.h>
using namespace std;
const long long N = 2000;
struct node {
  long long from, to, dis;
} a[N];
long long f[N], n, m, A, B, x, y;
inline long long find(long long z) {
  if (f[z] != z) return f[z] = find(f[z]);
  return z;
}
long long d[800][800], tot, id[800], siz[800], bh[800], ll;
vector<long long> v[800];
struct no {
  long long next, to, dis;
} G[N * N];
long long head[N], cnt;
void add(long long e, long long r, long long t) {
  G[++cnt] = {head[e], r, t};
  head[e] = cnt;
}
struct pa {
  long long id, st, val;
  friend bool operator<(pa x, pa y) { return x.val > y.val; }
};
priority_queue<pa> q;
long long dis[71][1 << 17];
long long vis[71][1 << 17];
void dij() {
  memset(dis, 10, sizeof(dis));
  if (!bh[1])
    q.push((pa){1, 0, 0}), dis[1][0] = 0;
  else
    q.push((pa){1, (1 << (bh[1] - 1)), 0}), dis[1][(1 << (bh[1] - 1))] = 0;
  while (!q.empty()) {
    pa u = q.top();
    q.pop();
    if (vis[u.id][u.st]) continue;
    vis[u.id][u.st] = 1;
    for (long long i = head[u.id]; i; i = G[i].next) {
      if (bh[u.id] != bh[G[i].to] and bh[G[i].to] and
          ((1 << (bh[G[i].to] - 1)) & (u.st)))
        continue;
      long long h = 0;
      if (bh[G[i].to]) h = (1 << (bh[G[i].to] - 1));
      if (dis[G[i].to][(h | u.st)] > dis[u.id][u.st] + G[i].dis) {
        dis[G[i].to][(h | u.st)] = dis[u.id][u.st] + G[i].dis;
        q.push((pa){G[i].to, (h | u.st), dis[G[i].to][(h | u.st)]});
      }
    }
  }
}
signed main() {
  cin >> n >> m >> A >> B;
  for (long long i = 1; i <= n; i++) f[i] = i;
  for (long long i = 1; i <= m; i++) {
    scanf("%d%d%d", &a[i].from, &a[i].to, &a[i].dis);
  }
  memset(d, 10, sizeof(d));
  for (long long i = 1; i <= m; i++) {
    if (a[i].dis == A) {
      f[find(a[i].from)] = find(a[i].to);
      d[a[i].from][a[i].to] = d[a[i].to][a[i].from] =
          min(d[a[i].from][a[i].to], A);
    }
    d[i][i] = 0;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long k = 1; k <= n; k++) {
      for (long long j = 1; j <= n; j++) {
        d[k][j] = min(d[k][j], d[k][i] + d[i][j]);
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (find(i) == i) id[i] = ++tot, v[tot].push_back(i), siz[tot] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    if (find(i) != i) {
      id[i] = id[find(i)];
      v[id[i]].push_back(i);
      siz[id[i]]++;
    }
  }
  for (long long i = 1; i <= tot; i++) {
    if (siz[i] <= 3) continue;
    ll++;
    for (long long k = 0; k < v[i].size(); k++) {
      bh[v[i][k]] = ll;
    }
  }
  for (long long i = 1; i <= m; i++) {
    if (id[find(a[i].from)] != id[find(a[i].to)] and a[i].dis == B) {
      add(a[i].from, a[i].to, a[i].dis);
      add(a[i].to, a[i].from, a[i].dis);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long k = i + 1; k <= n; k++) {
      if (find(i) != find(k)) continue;
      add(i, k, d[i][k]);
      add(k, i, d[i][k]);
    }
  }
  dij();
  for (long long i = 1; i <= n; i++) {
    long long minn = 2e9;
    for (long long k = 0; k < (1 << ll); k++) {
      minn = min(minn, dis[i][k]);
    }
    cout << minn << " ";
  }
}
