#include <bits/stdc++.h>
using namespace std;
struct E {
  int x, y;
  long long g, s;
} e[50020];
struct EDGE {
  int src, adj, next;
  long long w;
} edge[50020 * 2];
int n, m, top, pro, father[202], gh[202];
long long A, B, maxb;
bool cmp(const E &a, const E &b) { return a.g < b.g; }
int getfather(int x) {
  return father[x] == x ? x : father[x] = getfather(father[x]);
}
void addedge(int x, int y, long long w) {
  edge[++top].adj = y;
  edge[top].src = x;
  edge[top].w = w;
  edge[top].next = gh[x];
  gh[x] = top;
}
int found, rec[202], trec;
void dfs(int x, int y, int rt = 0) {
  if (x == y) {
    found = 1;
    return;
  }
  for (int p = gh[x]; p && !found; p = edge[p].next)
    if (edge[p].adj != rt) {
      rec[++trec] = p;
      dfs(edge[p].adj, y, x);
      if (!found) --trec;
    }
}
void del(int x, int y, int r = 1) {
  found = 0;
  trec = 0;
  dfs(x, y);
  long long maxw = -(1LL << 62);
  int mx = 0;
  for (int i = 1; i <= trec; i++)
    if (edge[rec[i]].w > maxw) {
      maxw = edge[rec[i]].w;
      mx = rec[i];
    }
  x = edge[mx].src;
  y = edge[mx].adj;
  if (r == 0) {
    if (mx == 0)
      maxb = 1LL << 62;
    else
      maxb = edge[mx].w;
    return;
  }
  for (int i = 0; i < 2; i++) {
    if (edge[gh[x]].adj == y)
      gh[x] = edge[gh[x]].next;
    else
      for (int p = gh[x]; p; p = edge[p].next)
        if (y == edge[edge[p].next].adj) {
          edge[p].next = edge[edge[p].next].next;
          break;
        }
    swap(x, y);
  }
}
void findmaxb() {
  maxb = -(1LL << 62);
  for (int x = 1; x <= n; x++)
    for (int p = gh[x]; p; p = edge[p].next)
      if (edge[p].w > maxb) maxb = edge[p].w;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%lld", &A);
  scanf("%lld", &B);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &e[i].x, &e[i].y);
    scanf("%lld", &e[i].g);
    scanf("%lld", &e[i].s);
  }
  for (int i = 1; i <= n; i++) father[i] = i;
  sort(e + 1, e + m + 1, cmp);
  pro = 0;
  top = 1;
  long long ans = 1LL << 62;
  for (int i = 1; i <= m; i++) {
    if (e[i].x == e[i].y) continue;
    if (getfather(e[i].x) != getfather(e[i].y)) {
      father[father[e[i].x]] = father[e[i].y];
      pro++;
    } else {
      del(e[i].x, e[i].y, 0);
      if (e[i].s > maxb) continue;
      del(e[i].x, e[i].y);
    }
    addedge(e[i].x, e[i].y, e[i].s);
    addedge(e[i].y, e[i].x, e[i].s);
    findmaxb();
    if (((n - 1) == (pro))) {
      ans = min(ans, e[i].g * A + maxb * B);
    }
  }
  if (ans == 1LL << 62) ans = -1;
  printf("%lld", ans);
  return 0;
}
