#include <bits/stdc++.h>
using namespace std;
struct node3 {
  int S, id;
};
queue<node3> F;
int n, m, t1, t2, len = 0;
int last[80], id[80], nid[80], fa[80], size[80], dis[1 << 18][80], ans[80];
bool bz[1 << 18][80];
struct node1 {
  int x, y, z, next;
} a[410];
struct node2 {
  int x, y, z;
} b[210];
void ins(int x, int y, int z) {
  a[++len] = (node1){x, y, z, last[x]};
  last[x] = len;
}
bool cmp(node2 x, node2 y) { return x.z < y.z; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void init() {
  int cnt = 0, ncnt = 0;
  sort(b + 1, b + m + 1, cmp);
  for (int i = 1; i <= n; i++) id[i] = i;
  for (int i = 1; i <= m; i++) {
    if (b[i].z == t2) break;
    int u1 = find(b[i].x), u2 = find(b[i].y);
    if (u1 != u2) fa[u1] = u2;
  }
  for (int i = 1; i <= n; i++) {
    size[find(i)]++;
    if (i == find(i)) id[i] = ++cnt;
  }
  for (int i = 1; i <= n; i++) id[i] = id[find(i)];
  for (int i = 1; i <= n; i++)
    if (size[i] >= 4) nid[i] = ++ncnt;
  for (int i = 1; i <= n; i++) nid[i] = nid[find(i)];
}
void spfa() {
  memset(dis, 63, sizeof(dis));
  dis[0][1] = 0;
  memset(bz, false, sizeof(bz));
  bz[0][1] = true;
  while (!F.empty()) F.pop();
  F.push((node3){0, 1});
  while (!F.empty()) {
    node3 NOW = F.front();
    int x = NOW.id;
    F.pop();
    for (int i = last[x]; i; i = a[i].next) {
      int y = a[i].y;
      if (id[x] == id[y] && a[i].z == t2) continue;
      if (nid[y] && (NOW.S & (1 << nid[y]))) continue;
      int tmp = NOW.S;
      if (nid[x] && nid[x] != nid[y]) tmp = (NOW.S | (1 << nid[x]));
      if (dis[NOW.S][x] + a[i].z < dis[tmp][y]) {
        dis[tmp][y] = dis[NOW.S][x] + a[i].z;
        ans[y] = min(ans[y], dis[tmp][y]);
        if (!bz[tmp][y]) bz[tmp][y] = true, F.push((node3){tmp, y});
      }
    }
    bz[NOW.S][x] = false;
  }
}
int main() {
  scanf("%d %d %d %d", &n, &m, &t1, &t2);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &b[i].x, &b[i].y, &b[i].z);
    ins(b[i].x, b[i].y, b[i].z), ins(b[i].y, b[i].x, b[i].z);
  }
  init();
  memset(ans, 63, sizeof(ans));
  ans[1] = 0;
  spfa();
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
