#include <bits/stdc++.h>
int main() {
  int n, m, i, j, k;
  long long int ans = -1000000000000000001;
  scanf("%d%d", &n, &m);
  long long int tommy[n], Banban[m];
  for (i = 0; i < n; i++) {
    scanf("%I64d", &tommy[i]);
  }
  for (j = 0; j < m; j++) {
    scanf("%I64d", &Banban[j]);
  }
  long long int exclude = tommy[0] * Banban[0];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (tommy[i] * Banban[j] > exclude) {
        exclude = tommy[i] * Banban[j];
        k = i;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (i != k) {
      for (j = 0; j < m; j++) {
        if (tommy[i] * Banban[j] > ans) {
          ans = tommy[i] * Banban[j];
        }
      }
    }
  }
  printf("%I64d", ans);
  return 0;
}
