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

int memo[51][51][51][51][2][3];

const int FLAG = INT_MAX;

int calc(const vector<int>& a, const vector<int>& b, int i1, int j1, int i2, int j2, bool t, int skip){
    if(memo[i1][j1][i2][j2][t][skip] != FLAG) return memo[i1][j1][i2][j2][t][skip];
    if(!t){
        if(i1 == (int)a.size()){
            if(skip == 2) return memo[i1][j1][i2][j2][t][skip] = 0;
            int sum = 0;
            for(int i = i2;i < i1;i++){
                sum += a[i] != -1 ? a[i] : 0;
            }
            for(int i = j2;i < j1;i++){
                sum -= b[i] != -1 ? b[i] : 0;
            }
            sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
            return memo[i1][j1][i2][j2][t][skip] = sum;
        }
        int res = skip == 2 ? 0 : INT_MIN;
        if(a[i1] == -1){
            res = max(res, -calc(a, b, i1 + 1, j1, i2, j1, !t, 0));
        }
        else{
            res = max(res, -calc(a, b, i1 + 1, j1, i2, j2, !t, 0));
        }
        if(skip < 2){
            int sum = 0;
            for(int i = i2;i < i1;i++){
                sum += a[i] != -1 ? a[i] : 0;
            }
            for(int i = j2;i < j1;i++){
                sum -= b[i] != -1 ? b[i] : 0;
            }
            sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
            res = max(res, sum);
        }
        return memo[i1][j1][i2][j2][t][skip] = res;
    }
    if(j1 == (int)b.size()){
        if(skip == 2) return memo[i1][j1][i2][j2][t][skip] = 0;
        int sum = 0;
        for(int i = i2;i < i1;i++){
            sum -= a[i] != -1 ? a[i] : 0;
        }
        for(int i = j2;i < j1;i++){
            sum += b[i] != -1 ? b[i] : 0;
        }
        sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
        return memo[i1][j1][i2][j2][t][skip] = sum;
    }
    int res = skip == 2 ? 0 : INT_MIN;
    if(b[j1] == -1){
        res = max(res, -calc(a, b, i1, j1 + 1, i1, j2, !t, 0));
    }
    else{
        res = max(res, -calc(a, b, i1, j1 + 1, i2, j2, !t, 0));
    }
    if(skip < 2){
        int sum = 0;
        for(int i = i2;i < i1;i++){
            sum -= a[i] != -1 ? a[i] : 0;
        }
        for(int i = j2;i < j1;i++){
            sum += b[i] != -1 ? b[i] : 0;
        }
        sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
        res = max(res, sum);
    }
    return memo[i1][j1][i2][j2][t][skip] = res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < m;i++){
        cin >> b[i];
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            for(int k = 0;k <= n;k++){
                for(int l = 0;l <= m;l++){
                    for(int o = 0;o < 2;o++){
                        for(int p = 0;p < 3;p++){
                            memo[i][j][k][l][o][p] = FLAG;
                        }
                    }
                }
            }
        }
    }
    cout << calc(a, b, 0, 0, 0, 0, false, 1) << endl;
    return 0;
}

