#include <bits/stdc++.h>
using namespace std;
long long a[21234];
long long b[21234];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(11);
  cout.setf(ios::fixed);
  long long an, bn;
  cin >> an >> bn;
  for (long long i = 0; i < an; i++) cin >> a[i];
  for (long long i = 0; i < bn; i++) cin >> b[i];
  long long max = -LLONG_MAX;
  long long anomax;
  for (long long i = 0; i < an; i++) {
    for (long long j = 0; j < bn; j++) {
      if (a[i] * b[j] > max) {
        max = a[i] * b[j];
        anomax = i;
      }
    }
  }
  max = -LLONG_MAX;
  for (long long i = 0; i < an; i++) {
    for (long long j = 0; j < bn; j++) {
      if (i != anomax && a[i] * b[j] > max) {
        max = a[i] * b[j];
      }
    }
  }
  cout << max << endl;
  return 0;
}
