#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  long long 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 mx = -1e18;
  long long idx = -1;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      long long p = a[i] * b[j];
      if (mx < p) {
        mx = p;
        idx = i;
      }
    }
  }
  long long ans = -1e18;
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      if (j != idx) {
        ans = max(ans, b[i] * a[j]);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
