#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-7;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
const int maxn = 50 + 10;
int a[maxn];
int b[maxn];
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  long long mx = -INF64, ban = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (1LL * a[i] * b[j] > mx) {
        mx = 1LL * a[i] * b[j];
        ban = i;
      }
    }
  }
  long long ans = -INF64;
  for (int i = 0; i < n; i++) {
    if (i == ban) continue;
    for (int j = 0; j < m; j++) {
      if (1LL * a[i] * b[j] > ans) ans = 1LL * a[i] * b[j];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
