#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  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];
  long long ans = (long long)1e18;
  for (int i = 0; i < n; i++) {
    long long k = (long long)-1e18;
    for (int j = 0; j < m; j++) {
      long long kk = (long long)-1e18;
      for (int jj = 0; jj < n; jj++) {
        if (jj == i) continue;
        if (a[jj] * b[j] > kk) kk = a[jj] * b[j];
      }
      if (k < kk) k = kk;
    }
    if (ans > k) ans = k;
  }
  cout << ans;
  return 0;
}
