#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + m);
  for (long long i = 0; i < n + m; i++) {
    cin >> a[i];
  }
  long long ret = 2e18;
  for (long long i = 0; i < n; i++) {
    long long Ret = -2e18;
    for (long long j = 0; j < n + m; j++) {
      for (long long k = 0; k < n + m; k++) {
        if (j < n && k >= n && j != i && k != i) {
          Ret = max(Ret, a[j] * a[k]);
        }
      }
    }
    ret = min(ret, Ret);
  }
  cout << ret;
  return 0;
}
