#include <bits/stdc++.h>

using namespace std;
int const MAX = 51;

int n[2];
int deck[2][MAX];
int sum[2][MAX];

const int IniVal = (1<<29)+1234321;
int dp[MAX][MAX][MAX][MAX][2][4];

int rec(int l1, int r1, int l2, int r2, int which, int pass) {

  auto& ret = dp[l1][r1][l2][r2][which][pass];
  if(ret != IniVal) return ret;

  if(pass == 3) {
    return ret = 0;
  }

  // pass
  ret = -rec(r2, r2, r1, r1, !which, pass + 1)
        + (sum[which][r1] - sum[which][l1])
        - (sum[!which][r2] - sum[!which][l2]);

  if(r1 == n[which])
    return ret;

  if(deck[which][r1] != -1)
    ret = max(ret, -rec(l2, r2, l1, r1 + 1, !which, 0));
  else
    ret = max(ret, -rec(r2, r2, l1, r1 + 1, !which, 0));

  return ret;
}
 
int main() {

  for(int i=0; i<MAX; i++)
    for(int j=0; j<MAX; j++)
      for(int k=0; k<MAX; k++)
        for(int l=0; l<MAX; l++)
          for(int a=0; a<2; a++)
            for(int b=0; b<4; b++)
              dp[i][j][k][l][a][b] = IniVal;

  for(int i=0; i<2; i++)
    cin >> n[i];

  for(int i=0; i<2; i++)
    for(int j=0; j<n[i]; j++)
      cin >> deck[i][j];

  for(int i=0; i<2; i++) {
    sum[i][0] = 0;
    for(int j=0; j<n[i]; j++) {
      int point = deck[i][j];
      if(point == -1) point = 0;
      sum[i][j + 1] = sum[i][j] + point;
    }
  }

  cout << rec(0, 0, 0, 0, 0, 0) << endl;

  return 0;
}