#include <bits/stdc++.h>
using namespace std;

int n, m;
vector<int> a, b;
map<tuple<int,int,int64_t,int64_t,bool,bool>, int64_t> checked;

int64_t solve(int x, int y, int64_t px, int64_t py, bool k, bool passed){
    tuple<int,int,int64_t,int64_t,bool,bool> key = tuple<int,int,int64_t,int64_t,bool,bool>{x, y, px, py, k, passed};
    if(checked.count(key)) return checked[key];

    int64_t cand[2];
    if(k == 0){
        if(passed)   cand[1] = 0;
        else         cand[1] = solve(x, y, 0, 0, !k, px == 0 && py == 0) + px - py;
        if(x >= n) return checked[key] = cand[1];
        if(a[x] > 0) cand[0] = solve(x + 1, y, px + a[x], py, !k, 0);
        else         cand[0] = solve(x + 1, y, px,        0,  !k, 0);
        return checked[key] = max(cand[0], cand[1]);
    }else{
        if(passed)   cand[1] = 0;
        else         cand[1] = solve(x, y, 0, 0, !k, px == 0 && py == 0) + px - py;
        if(y >= m) return checked[key] = cand[1];
        if(b[y] > 0) cand[0] = solve(x, y + 1, px, py + b[y], !k, 0);
        else         cand[0] = solve(x, y + 1, 0,  py       , !k, 0);
        return checked[key] = min(cand[0], cand[1]);
    }
}

int main(){
    cin >> n >> m;
    a.reserve(n);
    b.reserve(m);
    for(int i=0;i<n;++i){ int x; cin >> x; a.emplace_back(x); }
    for(int j=0;j<m;++j){ int y; cin >> y; b.emplace_back(y); }
    cout << solve(0, 0, 0, 0, 0, 0) << endl;
    
    return 0;
}
