#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define pb      push_back

#define ll      long long
#define int     long long

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

const int MOD1 = 1000000007;
const int MOD2 = 998244353;
const int N = 2e5 + 10;
const int INF = 1e18;

vector<tuple<int, int, int>> adj[N];

vector<int> p, d;
void dijkstra(int32_t s) {
	int32_t n = N;
	d.assign(n, INF);
	p.assign(n, -1);

	d[s] = 0;
	set<pair<int, int32_t>> q;
	q.insert({0, s});
	while (!q.empty()) {
		int v = q.begin()->second;
		q.erase(q.begin());

		for (auto [to, len, k] : adj[v]) {
			int nd = (d[v] + k - 1) / k * k + len;
			if (nd < d[to]) {
				q.erase({d[to], to});
				d[to] = nd;
				p[to] = v;
				q.insert({d[to], to});
			}
		}
	}
}

void solve() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	x--, y--;
	for (int i = 0; i < m; ++i) {
		int a, b, t, k;
		cin >> a >> b >> t >> k;
		a--, b--;
		adj[a].pb({b, t, k});
		adj[b].pb({a, t, k});
	}

	dijkstra(x);
	if (d[y] == INF) { d[y] = -1; }
	cout << d[y];
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
		cout << '\n';
	}
	return 0;
}
/*HAR HAR MAHADEV
ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
# include   <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;//typedef for datatype and #define for macro

# define    fast                ios_base::sync_with_stdio(false);cin.tie(NULL);
# define    MOD                 1000000007
# define    endl                '\n'
# define    FOR(i, a, b)        for (int i=a; i<(b); i++)
# define    F0R(i, a)           for (int i=0; i<(a); i++)
# define    FORd(i,a,b)         for (int i = (b)-1; i >= a; i--)
# define    F0Rd(i,a)           for (int i = (a)-1; i >= 0; i--)
# define    INF                 9e18
# define    PI                  3.14159265358979323846
# define    lb                  lower_bound
# define    ub                  upper_bound
# define    mp                  make_pair
# define    pb                  push_back
# define    fi                  first
# define    se                  second
# define    all(a)              a.begin(), a.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    fast;
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        double sx, sy, gx, gy;
        cin >> sx >> sy >> gx >> gy;
        cout << fixed << setprecision(10);
        cout << (gy * sx + gx * sy) / (sy + gy) << endl;
    }
    return 0;
}
/* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
  * WRITE STUFF DOWN
  * DON'T GET STUCK ON ONE APPROACH
*/