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