#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n, m;
int a[2][50];
bool used[51][51][101][2][3];
int ans[51][51][101][2][3];
//自分がi枚目、相手がj枚目、stackはk枚、自分はid、何回passされたか
int dfs(int i, int j, int k,int id,int pas) {
	if (used[i][j][k][id][pas])return ans[i][j][k][id][pas];
	used[i][j][k][id][pas] = true;
	vector<int> v;
	int nij[2] = { i - 1,j - 1 };
	rep(b, k) {
		int nid = (b % 2) ^ id^1;
		v.push_back(a[nid][nij[nid]]);
		nij[nid]--;
	}
	bool val[2] = { true,true };
	int sum = 0;
	rep(b, k) {
		if (b % 2) {
			if (v[b] < 0) {
				val[1] = false;
			}
			else {
				if (!val[0])continue;
				sum += v[b];
			}
		}
		else {
			if (v[b] < 0) {
				val[0] = false;
			}
			else {
				if (!val[1])continue;
				sum -= v[b];
			}
		}
	}
	//if (i == n && j == m)return ans[i][j][k][id][pas] = sum;
	int ma = -mod;
		//pass
		if (pas<=1) {
			ma = max(ma, -dfs(i, j, 0, id ^ 1,pas+1) + sum);
		}
		else {
			ma = max(ma, sum);
		}
	//not pass
	if (id == 0&&i<n) {
			ma = max(ma, -dfs(i + 1, j, k + 1, 1,0));
	}
	if (id == 1 && j < m) {
		ma = max(ma, -dfs(i, j + 1, k + 1, 0,0));
	}
	//cout << i << " " << j << " " << k << " " << id << " " << ma << endl;
	return ans[i][j][k][id][pas]= ma;
}
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[0][i];
	}
	rep(i, m) {
		cin >> a[1][i];
	}
	cout << dfs(0, 0, 0, 0,1) << endl;
	return 0;
}
