#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
long long calc(int);
int n, m, a[maxn], b[maxn];
int main() {
  scanf("%d%d", &n, &m);
  long long ans = 0x7fffffffffffffffll;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) ans = min(ans, calc(i));
  cout << ans;
  return 0;
}
long long calc(int x) {
  long long tmp = -0x7fffffffffffffffll;
  for (int i = 1; i <= n; i++)
    if (i != x) {
      for (int j = 1; j <= m; j++) tmp = max(tmp, (long long)a[i] * b[j]);
    }
  return tmp;
}
