#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200 + 10;
const int MAX_M = 50000 + 10;
const int INF = 1000000000 + 7;
const long long INF2 = 2000000000000000010LL;
struct info {
  int s, t, a, b;
  info() {}
  info(int _s, int _t, int _a, int _b) : s(_s), t(_t), a(_a), b(_b) {}
  int operator<(const info &that) const { return a < that.a; }
};
int N, M;
int S, G;
int tu, tv;
long long tb;
int vis[MAX_N];
vector<pair<int, int> > adj[MAX_N];
info e[MAX_M];
int findRoute(int u, int t) {
  if (u == t) return true;
  vis[u] = true;
  int v;
  for (__typeof(adj[u].begin()) e = adj[u].begin(); e != adj[u].end(); ++e) {
    v = e->first;
    if (vis[v]) continue;
    if (findRoute(v, t)) {
      if (e->second > tb) {
        tb = e->second;
        tu = u;
        tv = v;
      }
      return true;
    }
  }
  return false;
}
void erase(int u, int v) {
  for (__typeof(adj[u].begin()) e = adj[u].begin(); e != adj[u].end(); ++e)
    if (e->first == v) {
      adj[u].erase(e);
      break;
    }
  for (__typeof(adj[v].begin()) e = adj[v].begin(); e != adj[v].end(); ++e)
    if (e->first == u) {
      adj[v].erase(e);
      break;
    }
}
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  int v;
  for (__typeof(adj[u].begin()) e = adj[u].begin(); e != adj[u].end(); ++e) {
    v = e->first;
    tb = max(tb, (long long)e->second);
    dfs(v);
  }
}
void solve() {
  scanf("%d%d", &N, &M);
  scanf("%d%d", &G, &S);
  for (int i = 0; i < N; ++i) adj[i].clear();
  for (int i = 0; i < M; ++i) {
    scanf("%d%d%d%d", &e[i].s, &e[i].t, &e[i].a, &e[i].b);
    --e[i].s;
    --e[i].t;
  }
  sort(e, e + M);
  int u, v;
  long long ret = INF2;
  for (int i = 0; i < M; ++i) {
    u = e[i].s;
    v = e[i].t;
    if (u == v) continue;
    tb = -1;
    fill(vis, vis + N, false);
    findRoute(u, v);
    if (tb == -1) {
      adj[u].push_back(make_pair(v, e[i].b));
      adj[v].push_back(make_pair(u, e[i].b));
    } else if (tb > e[i].b) {
      erase(tv, tu);
      adj[u].push_back(make_pair(v, e[i].b));
      adj[v].push_back(make_pair(u, e[i].b));
    }
    tb = 0;
    fill(vis, vis + N, 0);
    dfs(0);
    int cnt = 0;
    for (int j = 0; j < N; ++j) cnt += vis[j];
    if (cnt == N) ret = min(ret, tb * S + (long long)e[i].a * G);
  }
  if (ret == INF2)
    cout << -1 << endl;
  else
    cout << ret << endl;
}
int main() {
  solve();
  return 0;
}
