#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), b(m);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < m; ++i) cin >> b[i];
  long long ans = 2e18;
  for (long long i = 0; i < n; ++i) {
    long long mx = -2e18;
    for (long long j = 0; j < n; ++j) {
      if (i != j) {
        for (long long k = 0; k < m; ++k) mx = max(mx, a[j] * b[k]);
      }
    }
    ans = min(ans, mx);
  }
  cout << ans << '\n';
}
