#include <bits/stdc++.h>
using namespace std;
int n, m;
long a[50], b[50];
long long ans, inf = 1000000000000000001;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  ans = inf;
  for (int i = 0; i < n; ++i) {
    long long now = -inf;
    for (int j = 0; j < n; ++j)
      if (j != i)
        for (int k = 0; k < m; ++k) {
          if (now < (long long)a[j] * b[k]) now = (long long)a[j] * b[k];
        }
    if (ans > now) ans = now;
  }
  cout << ans;
  getchar();
  getchar();
  return 0;
}
