#include <bits/stdc++.h>
using namespace std;
long long a[55], b[55];
bool c[55], d[55];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      c[i] = true;
    }
    for (int i = 0; i < m; i++) {
      scanf("%lld", &b[i]);
      d[i] = true;
    }
    long long ans = 0;
    int numa = n;
    int numb = m;
    while (numa > 1 && numb > 0) {
      bool t = false;
      long long max = 0, maxa = 0, maxb = 0;
      for (int i = 0; i < n; i++)
        if (c[i])
          for (int j = 0; j < m; j++)
            if (d[j]) {
              if (!t || a[i] * b[j] > max) {
                t = true;
                maxa = i;
                maxb = j;
                max = a[i] * b[j];
              }
            }
      numa--;
      c[maxa] = false;
      t = false;
      max = 0;
      maxa = 0;
      maxb = 0;
      for (int i = 0; i < n; i++)
        if (c[i])
          for (int j = 0; j < m; j++)
            if (d[j]) {
              if (!t || a[i] * b[j] > max) {
                t = true;
                maxa = i;
                maxb = j;
                max = a[i] * b[j];
              }
            }
      numa--;
      numb--;
      c[maxa] = false;
      d[maxb] = false;
      ans += a[maxa] * b[maxb];
      break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
