#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
int32_t main() {
  int n, m;
  cin >> n >> m;
  long long ans = LLONG_MAX;
  vector<long long> a(n), b(m);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (m); ++i) cin >> b[i];
  for (int i = 0; i < (n); ++i) {
    long long curr = -LLONG_MAX;
    for (int j = 0; j < (n); ++j) {
      if (i == j) continue;
      for (int k = 0; k < (m); ++k) {
        curr = max(curr, b[k] * a[j]);
      }
    }
    ans = min(ans, curr);
  }
  cout << ans << endl;
}
