#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
int main() {
  long long i, j, k, l, p, q, r, x, y, z, n, m, c(0), t, h, mn = pow(2, 62) - 1,
                                                            mx = 0;
  cin >> n >> m;
  long long a[n + 1], b[m + 1];
  vector<pair<long long, long long> > v;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (j = 1; j <= m; j++) scanf("%lld", &b[j]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) v.push_back(make_pair(a[i] * b[j], i));
  }
  sort(v.begin(), v.end());
  p = v[v.size() - 1].second;
  vector<long long> ans;
  for (i = 1; i <= n; i++) {
    if (i == p) continue;
    for (j = 1; j <= m; j++) ans.push_back(a[i] * b[j]);
  }
  sort(ans.begin(), ans.end());
  cout << ans[ans.size() - 1] << endl;
}
