#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long int first[n + 1], second[m + 1];
  for (int i = 0; i < n; i++) {
    cin >> first[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> second[i];
  }
  long long int minimum1 = 2e18;
  for (int i = 0; i < n; i++) {
    long long int maximum = -2e18;
    for (int j = 0; j < n; j++) {
      if (j != i) {
        for (int k = 0; k < m; k++) {
          maximum = max(maximum, first[j] * second[k]);
        }
      }
    }
    minimum1 = min(minimum1, maximum);
  }
  cout << minimum1 << endl;
  return 0;
}
