#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long a[100];
  long long b[100];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  long long ans = 1000000000000000000LL;
  for (int i = 1; i <= n; i++) {
    long long mn = -1000000000000000000LL;
    for (int j = 1; j <= m; j++)
      for (int k = 1; k <= n; k++) {
        if (k == i) continue;
        mn = max(mn, a[k] * b[j]);
      }
    ans = min(ans, mn);
  }
  cout << ans << endl;
}
