#include <bits/stdc++.h>
using namespace std;
int a[55], b[55];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) scanf("%d", b + i);
  long long ans = 1ll << 62;
  for (int x = 1; x <= n; x++) {
    long long maxv = -(1ll << 62);
    for (int y = 1; y <= n; y++) {
      if (x == y) continue;
      for (int z = 1; z <= m; z++) {
        maxv = max(maxv, (long long)a[y] * b[z]);
      }
    }
    ans = min(ans, maxv);
  }
  printf("%lld\n", ans);
  return 0;
}
