#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  static char c;
  while (!isdigit(c = getchar()))
    ;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
void read(long long &x) {
  static char c;
  while (!isdigit(c = getchar()))
    ;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
void chkmax(int &x, int y) {
  if (y > x) x = y;
}
void chkmin(int &x, int y) {
  if (y < x) x = y;
}
void chkmax(long long &x, long long y) {
  if (y > x) x = y;
}
void chkmin(long long &x, long long y) {
  if (y < x) x = y;
}
const int N = 75, M = 205;
int n, m, _a, _b;
struct Edge {
  int v, nxt, w;
} ed[M << 1];
int head[N], cnt;
void adde(int u, int v, int w) {
  ed[++cnt] = (Edge){v, head[u], w}, head[u] = cnt;
}
void add(int u, int v, int w) { adde(u, v, w), adde(v, u, w); }
int bel[N], tot, siz;
void dfs(int now, int blc) {
  bel[now] = blc, ++siz;
  for (int i = head[now]; i; i = ed[i].nxt) {
    int v = ed[i].v, w = ed[i].w;
    if (w != _a || bel[v] == blc) continue;
    dfs(v, blc);
  }
}
int dis[N][(1 << 17) + 5];
deque<int> Q;
void Work() {
  read(n), read(m), read(_a), read(_b);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    read(u), read(v), read(w);
    add(u, v, w);
  }
  for (int i = 1; i <= n; ++i) {
    if (bel[i] != 0) continue;
    ++tot, siz = 0;
    dfs(i, tot);
    if (siz <= 3) dfs(i, -i), --tot;
  }
  for (int i = 1; i <= n; ++i)
    for (int S = 0; S < (1 << tot); ++S) dis[i][S] = 1e9;
  dis[1][0] = 0;
  Q.push_back(1);
  while (Q.size()) {
    int u = Q.front() % n, S = Q.front() / n;
    Q.pop_front();
    if (!u) u = n;
    for (int i = head[u]; i; i = ed[i].nxt) {
      int v = ed[i].v, w = ed[i].w;
      if (w == _b && bel[v] > 0 && ((S >> (bel[v] - 1)) & 1)) continue;
      if (w == _b && bel[u] == bel[v]) continue;
      int _nxtS = ((w == _a || bel[u] < 0) ? S : (S | (1 << (bel[u] - 1))));
      if (dis[v][_nxtS] <= dis[u][S] + w) continue;
      if (w == _a)
        dis[v][_nxtS] = dis[u][S] + _a, Q.push_front(_nxtS * n + v % n);
      else
        dis[v][_nxtS] = dis[u][S] + _b, Q.push_back(_nxtS * n + v % n);
    }
  }
  printf("0 ");
  for (int i = 2; i <= n; ++i) {
    int ans = 1e9;
    for (int S = 0; S < (1 << tot); ++S)
      if (dis[i][S]) chkmin(ans, dis[i][S]);
    printf("%d ", ans);
  }
}
int main() { Work(); }
