#include <bits/stdc++.h>
using namespace std;
    
#define M 1000000007
int n[2], a[2][50], memo[2][51][51][101][2];
int score(int p, int ai[2], int st) {
    int q = p, ret = 0;
    int ait[2] = {ai[0], ai[1]};
    bool b[2] = {true, true};
    for (int i = 0; i < st && (b[0] || b[1]); ++i) {
        q ^= 1;
        --ait[q];
        if (a[q][ait[q]] == -1){
            b[!q] = false;
            continue;
        }
        if (b[q]) ret += (p == q) ? a[q][ait[q]] : -a[q][ait[q]];
    }
    return ret;
}
int dfs(int p, int ai[2], int st, int finflg) {
    if (memo[p][ai[0]][ai[1]][st][finflg] > -M) return memo[p][ai[0]][ai[1]][st][finflg];
    
    int s = score(p, ai, st);
    if (ai[p] == n[p]) return memo[p][ai[0]][ai[1]][st][finflg] = s - (finflg ? 0 : dfs(!p, ai, 0, !st));
    
    int usei[2];
    usei[p] = ai[p] + 1;
    usei[!p] = ai[!p];
    return memo[p][ai[0]][ai[1]][st][finflg] = max(s - (finflg ? 0 : dfs(!p, ai, 0, !st)), -dfs(!p, usei, st + 1, 0));
}
int main(){
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 51; ++j)
            for (int k = 0; k < 51; ++k)
                for (int l = 0; l < 101; ++l)
                    for (int p = 0; p < 2; ++p)
                        memo[i][j][k][l][p] = -M;
    
    cin >> n[0] >> n[1];
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < n[i]; ++j)
            cin >> a[i][j];
    
    int ini[2] = {};
    cout << dfs(0, ini, 0, 0) << "\n";
    
    return 0;
}