#include <bits/stdc++.h>
using namespace std;
long long num[55], num2[55];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (n); i++) {
    scanf("%lld", &num[i]);
  }
  sort(num + 1, num + n + 1);
  for (int i = (1); i <= (m); i++) {
    scanf("%lld", &num2[i]);
  }
  sort(num2 + 1, num2 + m + 1);
  if (num2[m] <= 0) {
    if (num[2] <= 0) {
      printf("%lld\n", 1LL * num[2] * num2[1]);
    } else {
      printf("%lld\n", 1LL * num[2] * num2[m]);
    }
  } else if (num2[1] >= 0) {
    if (num[n] >= 0) {
      printf("%lld\n", 1LL * num[n - 1] * num2[m]);
    } else {
      printf("%lld\n", 1LL * num[n - 1] * num2[1]);
    }
  } else {
    long long x = num[1] * num2[1];
    long long y = num[n] * num2[m];
    printf("%lld\n",
           min(max(num[2] * num2[1], y), max(x, num[n - 1] * num2[m])));
  }
  return 0;
}
