    #pragma GCC optimize ("O3")
    #pragma GCC target ("sse4")

    #include <bits/stdc++.h>

    using namespace std;

    typedef long long ll;
    typedef long double ld;
    typedef complex<ld> cd;

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

    typedef vector<int> vi;
    typedef vector<ld> vd;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<cd> vcd;

    #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 trav(a,x) for (auto& a : x)
    #define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
    #define ins insert

    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    const int MOD = 1000000007;
    const char nl = '\n';
    const int MX = 100001; //check the limits, dummy
    const char sp =' ';
    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0);
        ll x1,x2,y1,y2;
        cin >> x1>>y1 >>x2 >>y2;
        double a=(double)((x2*y1)+(x1*y2))/(y1+y2);
        printf("%.10f",a);
        return 0;
    }

    // read the question correctly (ll vs int)
    // template by bqi343(Benq),Geothermal.
    /* 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
    */



#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<queue>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

short A[501][501], B[501][501];
int D[1 << 18];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int tiisaikazu() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int tmp = *(int*)ci;
	int dig = 36 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	ci += 40 - dig >> 3;
	return tmp;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H = tiisaikazu(), W = tiisaikazu();
	rep(i, H) rep(j, W - 1) A[i][j] = tiisaikazu() << 1;
	rep(i, H - 1) rep(j, W) B[i][j] = tiisaikazu() << 1;

	priority_queue<ll, vector<ll>, greater<ll>> q;
	D[0] = -2e9 + 1;
	q.push((ll)D[0] << 32);
	int owa = (H - 1) << 9 | W - 1;

	while (q.size()) {
		auto tmp = q.top();
		q.pop();
		int d0 = tmp >> 32;
		int hwp = tmp & (1 << 20) - 1;
		if (D[hwp] != d0) continue;

		int h = hwp >> 9;
		int w = hwp & 511;
		int p = (d0 & 1) << 1 | 1;
		d0 |= 1;

		if (hwp == owa) break;

		if (w > 0) if (D[hwp - 1] > d0 + A[h][w - 1]) {
			D[hwp - 1] = d0 + A[h][w - 1];
			q.push((ll)(d0 + A[h][w - 1]) << 32 | hwp - 1);
		}
		if (w < W - 1) if (D[hwp + 1] > d0 + A[h][w]) {
			D[hwp + 1] = d0 + A[h][w];
			q.push((ll)(d0 + A[h][w]) << 32 | hwp + 1);
		}
		if (h > 0) if (D[hwp - 512] > d0 + p) {
			D[hwp - 512] = d0 + p;
			q.push((ll)(d0 + p) << 32 | hwp - 512);
		}
		if (h < H - 1) if (D[hwp + 512] > d0 + B[h][w]) {
			D[hwp + 512] = d0 + B[h][w];
			q.push((ll)(d0 + B[h][w]) << 32 | hwp + 512);
		}
	}

	co(D[owa] - D[0] >> 1);

	Would you please return 0;
}