#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int INF = 1000000000;

int dp[2][2][60][60][120];

int pt(const vector<int> &a, const vector<int> &b, int p, int i, int j, int h) {
  int sum = 0;
  bool addp = true;
  bool addo = true;
  REP(k,h) {
    if((k%2) == 0) {
      if (p) {
        if (a[i-1-k/2] == -1) addp = false;
      } else {
        if (b[j-1-k/2] == -1) addp = false;
      }
      if (addo) {
        if (p) {
          sum -= max(0, a[i-1-k/2]);
        } else {
          sum -= max(0, b[j-1-k/2]);
        }
      }
    } else {
      if (p) {
        if (b[j-1-k/2] == -1) addo = false;
      } else {
        if (a[i-1-k/2] == -1) addo = false;
      }
      if (addp) {
        if (p) {
          sum += max(0, b[j-1-k/2]);
        } else {
          sum += max(0, a[i-1-k/2]);
        }
      }
    }
  }
  return sum;
}

int solve(int p, int q, int i, int j, int h, const vector<int> &a, const vector<int> &b) {
  if (dp[p][q][i][j][h] != -INF) {
    return dp[p][q][i][j][h];
  }
  int pass, play = -INF+1;
  if (h) {
    pass = -solve(1-p, 0, i, j, 0, a, b) + pt(a, b, p, i, j, h);
  } else if (q == 0) {
    pass = -solve(1-p, 1, i, j, 0, a, b);
  } else {
    pass = 0;
  }
  if (p) {
    if (j < b.size()) {
      play = -solve(1-p, 0, i, j+1, h+1, a, b);
    }
  } else {
    if (i < a.size()) {
      play = -solve(1-p, 0, i+1, j, h+1, a, b);
    }
  }
  dp[p][q][i][j][h] = max(pass, play);
  return dp[p][q][i][j][h];
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  REP(i,n) cin>>a[i];
  vector<int> b(m);
  REP(i,m) cin>>b[i];
  REP(p,2)REP(q,2)REP(i,n+1)REP(j,m+1)REP(h,n+m+1) dp[p][q][i][j][h] = -INF;
  int res = solve(0, 0, 0, 0, 0, a, b);
  cout << res << endl;
  return 0;
}