#include <bits/stdc++.h>
using namespace std;
int n, m;
long long G, S;
int pre[205];
struct Edge {
  long long x, y;
  long long g, s;
  Edge() {}
  Edge(long long a, long long b, long long c, long long d)
      : x(a), y(b), g(c), s(d) {}
} edge[50005];
int find(int x) {
  if (pre[x] != x) pre[x] = find(pre[x]);
  return pre[x];
}
bool cmp(Edge a, Edge b) { return a.g < b.g; }
Edge MST[205];
int main() {
  cin >> n >> m;
  cin >> G >> S;
  for (int i = 1; i <= m; i++)
    cin >> edge[i].x >> edge[i].y >> edge[i].g >> edge[i].s;
  sort(edge + 1, edge + 1 + m, cmp);
  int e = 0, tmp;
  long long ans = -1;
  for (int i = 1; i <= m; i++) {
    tmp = 0;
    for (int j = 1; j <= n; j++) pre[j] = j;
    MST[e++] = edge[i];
    for (int j = e - 1; j >= 1; j--)
      if (MST[j].s < MST[j - 1].s) swap(MST[j], MST[j - 1]);
    for (int j = 0; j < e; j++) {
      int pre_x = find(MST[j].x);
      int pre_y = find(MST[j].y);
      if (pre_x != pre_y) {
        pre[pre_y] = pre_x;
        MST[tmp++] = MST[j];
      }
    }
    if (tmp == n - 1 && (ans == -1 || ans > G * edge[i].g + S * MST[n - 2].s))
      ans = G * edge[i].g + S * MST[n - 2].s;
    e = tmp;
  }
  cout << ans << endl;
  return 0;
}
