#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  long long int arr1[123], arr2[123];
  for (int i = 0; i < N; i++) {
    cin >> arr1[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> arr2[i];
  }
  long long i, j, max = LLONG_MIN, next = 0;
  long long val;
  for (i = 0; i < M; i++) {
    for (j = 0; j < N; j++) {
      val = arr2[i] * arr1[j];
      if (val > max) {
        next = j;
        max = val;
      }
    }
  }
  max = LLONG_MIN;
  for (i = 0; i < N; i++) {
    if (next == i) {
      continue;
    }
    for (j = 0; j < M; j++) {
      val = arr2[j] * arr1[i];
      if (val > max) {
        max = val;
      }
    }
  }
  cout << max << endl;
}
