#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  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 = INF;
  for (long long i = 0; i < n; ++i) {
    long long res = -INF;
    for (long long j = 0; j < n; ++j) {
      if (i != j) {
        for (long long k = 0; k < m; ++k) {
          res = max(res, a[j] * b[k]);
        }
      }
    }
    ans = min(ans, res);
  }
  cout << ans;
}
