#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
long long n, m, x, mini, maxi;
vector<long long> a;
vector<long long> b;
void solve() {
  a.clear();
  b.clear();
  for (int i = 0; i < n; ++i) {
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < m; ++i) {
    cin >> x;
    b.push_back(x);
  }
  long long mini = 2e18;
  for (int i = 0; i < n; ++i) {
    maxi = -2e18;
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        for (int k = 0; k < m; ++k) {
          maxi = max(maxi, a[j] * b[k]);
        }
      }
    }
    mini = min(mini, maxi);
  }
  cout << mini << endl;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  while (cin >> n >> m) {
    solve();
  }
  return 0;
}
