#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200005];
int main() {
  long long n, m;
  cin >> n >> m;
  long long arr[n], arr1[m];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  for (long long i = 0; i < m; i++) cin >> arr1[i];
  long long p = 0LL;
  long long mx = -(long long)1e18;
  long long ans = (long long)1e18;
  for (long long i = 0; i < n; i++) {
    long long mx = -(long long)1e18;
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < m; k++) {
        if (j != i) {
          p = 1LL * arr[j] * arr1[k];
          mx = max(mx, p);
        }
      }
    }
    ans = min(ans, mx);
  }
  cout << ans << endl;
  return 0;
}
