#include <bits/stdc++.h>
using namespace std;
const int N = 75, inf = 0x3f3f3f3f;
int n, m, va, vb, tot, cnte;
int head[N], fa[N], g[N][N], siz[N], id[N], f[1 << 17][N];
bool vis[1 << 17][N];
struct edge {
  int to, nxt, val;
} e[405];
void add(int u, int v, int w) {
  e[++cnte] = (edge){v, head[u], w};
  head[u] = cnte;
}
struct node {
  int d, s, u;
  bool operator<(const node x) const { return d > x.d; }
};
int Find(int u) { return fa[u] == u ? u : fa[u] = Find(fa[u]); }
void Merge(int u, int v) {
  u = Find(u);
  v = Find(v);
  if (u == v) return;
  fa[v] = u;
  siz[u] += siz[v];
}
int main() {
  int x, y, z;
  scanf("%d%d%d%d", &n, &m, &va, &vb);
  memset(g, 0x3f, sizeof(g));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    g[x][y] = g[y][x] = min(g[x][y], z);
  }
  for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (g[i][j] == va) Merge(i, j);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (g[i][j] < inf) {
        if (g[i][j] == va)
          add(i, j, g[i][j]);
        else if (Find(i) != Find(j))
          add(i, j, g[i][j]);
      }
  for (int i = 1; i <= n; i++)
    if (fa[i] == i && siz[i] >= 4) id[i] = ++tot;
  for (int i = 1; i <= n; i++) id[i] = id[Find(i)];
  memset(f, 0x3f, sizeof(f));
  int st = id[1] ? 1 << (id[1] - 1) : 0;
  f[st][1] = 0;
  priority_queue<node> q;
  q.push((node){0, st, 1});
  while (!q.empty()) {
    node qu = q.top();
    q.pop();
    int u = qu.u, snow = qu.s;
    if (vis[snow][u]) continue;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to, w = e[i].val;
      if (w == inf) continue;
      if (w == vb && id[v] && (snow & (1 << (id[v] - 1)))) continue;
      int sv = id[v] ? snow | 1 << (id[v] - 1) : snow;
      if (!vis[sv][v] && f[sv][v] > f[snow][u] + w)
        f[sv][v] = f[snow][u] + w, q.push((node){f[sv][v], sv, v});
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = inf;
    for (int j = 0; j < (1 << tot); j++)
      if (!id[i] || (j & (1 << (id[i] - 1)))) ans = min(ans, f[j][i]);
    printf("%d ", ans);
  }
  return 0;
}
