#include <bits/stdc++.h>
using namespace std;
long long i, j, a[101], b[101], ans, k, n, m;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= m; i++) cin >> b[i];
  sort(b + 1, b + 1 + m);
  k = -1e18 - 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      if (a[i] * b[j] > k) {
        k = a[i] * b[j];
        ans = i;
      }
  }
  k = -1e18 - 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      if (a[i] * b[j] > k && i != ans) k = a[i] * b[j];
  }
  cout << k;
}
