#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using P2 = pair<ll, P>;
vector<ll> d;
ll inf = 1e18;

ll c1(ll t, ll c, ll d) {
    return t + c + (d / (t + 1));
}

ll culc(ll t, ll c, ll d) {
    int kouho = (double)(sqrt(d)+0.00001) - 1;
    ll ans = c1(t, c, d);
    for (int i = kouho - 10; i <= kouho + 10; i++) {
        if (i <= t)continue;
        ans = min(ans, c1(i, c, d));
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<P2>> g(n);
    rep(i, m) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        g[a].push_back(P2(b, P(c, d)));
        g[b].push_back(P2(a, P(c, d)));
    }
    d = vector<ll>(n, inf);
    priority_queue<P, vector<P>, greater<P>> que;
    d[0] = 0;
    que.push(P(0, 0));

    while (!que.empty()) {
        ll dist = que.top().first;
        int s = que.top().second;
        que.pop();
        if (d[s] < dist)continue;
        for (auto nextP : g[s]) {
            int next = nextP.first;
            int cv = nextP.second.first;
            int dv = nextP.second.second;
            ll cost = culc(d[s], cv, dv);
            if (d[next] <= cost)continue;
            d[next] = cost;
            que.push(P(d[next], next));
        }
    }

    if (d[n - 1] == inf)cout << -1 << endl;
    else cout << d[n - 1] << endl;
    return 0;

}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	double A, B, C, D;
	cin >> A >> B >> C>> D;

	double ans = abs(A - C) / (B + D) * B;
	if (C > A)
		ans += A;
	else
		ans = A - ans;

	cout << fixed <<setprecision(15) << ans << endl;
}