#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.141593;
const long long mod = 1000000007;
const long long INF = (1LL << 60) - 1;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
string ds = "RLDU";
long long v[1000100] = {0};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m, ans = INF, tmp = -INF;
  cin >> n >> m;
  long long a[n], b[m];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) {
    tmp = -INF;
    for (long long j = 0; j < n; j++) {
      if (j != i) {
        for (long long k = 0; k < m; k++) tmp = max(tmp, a[j] * b[k]);
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}
