#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100], b[100], ans = -2ll, i, j, sc = 0, maxt = -1;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long aa, bb;
  aa = -1000000000;
  bb = 1000000000;
  ans = aa * bb;
  maxt = ans;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) cin >> b[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i] * b[j] > maxt) {
        maxt = a[i] * b[j];
        sc = i;
      }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i] * b[j] > ans && i != sc) {
        ans = a[i] * b[j];
      }
  cout << ans;
  return 0;
}
