#include <bits/stdc++.h>
const int maxn = 500 + 10;
const int N = 2500 + 100;
long long a[maxn], b[maxn];
long long mul[N], ans[N];
int main() {
  int n, m, k = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < m; i++) scanf("%lld", &b[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) mul[k++] = a[i] * b[j];
  std::sort(mul, mul + k);
  long long maxx = mul[k - 1];
  int cnt = 0, id;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i] * b[j] == maxx) {
        id = i;
        break;
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (i != id) ans[cnt++] = a[i] * b[j];
  std::sort(ans, ans + cnt);
  std::cout << ans[cnt - 1];
}
