#include <bits/stdc++.h>
using namespace std;
const int int_MAX = 0x7fffffff;
const int int_MIN = -int_MAX;
const long long ll_MAX = 0x7fffffffffffffff;
const long long ll_MIN = -ll_MAX;
int main() {
  int n, m;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  long long a[n], b[m];
  for (int i = 0; i < n; ++i) scanf("%I64d", &a[i]);
  ;
  for (int i = 0; i < m; ++i) scanf("%I64d", &b[i]);
  ;
  long long res = ll_MAX;
  for (int i = 0; i < n; ++i) {
    long long t = ll_MIN;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      for (int k = 0; k < m; ++k) {
        t = max(t, a[j] * b[k]);
      }
    }
    res = min(res, t);
  }
  cout << res;
  return 0;
}
