#include <bits/stdc++.h>
using namespace std;
long long G, S, ans = 2000000000000000006;
int fa[206], n, m, SS[206 * 2], SSS[206 * 2], cnt;
struct node {
  int l, r;
  long long g, s;
} a[50006];
bool cmp(node a, node b) {
  if (a.g != b.g) return a.g < b.g;
  return a.s < b.s;
}
int root(int x) {
  if (fa[x] == x) return x;
  fa[x] = root(fa[x]);
  return fa[x];
}
int main() {
  scanf("%d%d%I64d%I64d", &n, &m, &G, &S);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%I64d%I64d", &a[i].l, &a[i].r, &a[i].g, &a[i].s);
  sort(a + 1, a + 1 + m, cmp);
  for (int k = 1; k <= m; k++) {
    int cnt1 = 0;
    long long ans1 = 0;
    for (int i = 1; i <= n; i++) fa[i] = i;
    SS[++cnt] = k;
    for (int i = cnt; i > 1; i--)
      if (a[SS[i]].s < a[SS[i - 1]].s)
        swap(SS[i], SS[i - 1]);
      else
        break;
    for (int i = 1; i <= cnt; i++) {
      int l = a[SS[i]].l;
      int r = a[SS[i]].r;
      if (root(l) != root(r)) {
        fa[root(l)] = root(r);
        ans1 = a[SS[i]].s;
        SSS[++cnt1] = SS[i];
      }
    }
    cnt = cnt1;
    for (int i = 1; i <= cnt1; i++) SS[i] = SSS[i];
    if (cnt1 == n - 1) ans = min(ans, ans1 * S + a[k].g * G);
  }
  if (ans != 2000000000000000006)
    printf("%I64d", ans);
  else
    printf("-1");
}
