#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, maxdig, maxm = -1000000000000000001, second;
  cin >> n >> m;
  long long *a = new long long[n];
  long long *b = new long long[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i] * b[j] > maxm) {
        maxm = a[i] * b[j];
        maxdig = i;
      }
    }
  }
  maxm = -1000000000000000001;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i] * b[j] > maxm && i != maxdig) {
        maxm = a[i] * b[j];
      }
    }
  }
  cout << maxm;
  return 0;
}
