#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a[60], b[60];
  long long int c, d, i, j, e, maxn, mins = 0x3f3f3f3f;
  mins *= -1;
  maxn = mins;
  cin >> c >> d;
  for (i = 0; i < c; i++) scanf("%I64d", &a[i]);
  for (i = 0; i < d; i++) scanf("%I64d", &b[i]);
  maxn = a[0] * b[0];
  e = 0;
  for (i = 0; i < c; i++) {
    for (j = 0; j < d; j++) {
      if (a[i] * b[j] > maxn) {
        maxn = a[i] * b[j];
        e = i;
      }
    }
  }
  if (e == 0)
    maxn = a[1] * b[0];
  else
    maxn = a[0] * b[0];
  for (i = 0; i < c; i++) {
    if (i == e) continue;
    for (j = 0; j < d; j++) {
      if (a[i] * b[j] > maxn) {
        maxn = a[i] * b[j];
      }
    }
  }
  printf("%I64d\n", maxn);
  return 0;
}
