#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
long long n, m;
long long a[55], b[55];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%lld", &b[i]);
  long long maxn = -INF, tmp = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (a[i] * b[j] > maxn || maxn == -INF) {
        maxn = a[i] * b[j];
        tmp = i;
      }
    }
  maxn = -INF;
  for (int i = 1; i <= n; i++) {
    if (i == tmp) continue;
    for (int j = 1; j <= m; j++)
      if (a[i] * b[j] > maxn || maxn == -INF) maxn = a[i] * b[j];
  }
  printf("%lld", maxn);
  return 0;
}
