#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n], b[m], flag = 0, max1 = 0, min1 = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    max1 = max(max1, a[i]);
    min1 = min(min1, a[i]);
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    if (b[i] > 0) flag = 1;
  }
  long long int c[m * n], count = 0;
  for (int i = 0; i < n * m; i++) c[i] = -(1e18);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[count] = a[i] * b[j];
      count++;
    }
  }
  long long int maxindex = 0;
  for (int i = 0; i < n * m; i++) {
    if (c[maxindex] < c[i]) maxindex = i;
  }
  long long int k = floor((maxindex + 1) / m);
  if (maxindex % m == m - 1) k--;
  long long int d[n * m];
  for (int i = 0; i < n * m; i++) d[i] = -(1e18);
  long long int temp = 0;
  for (int i = 0; i < n; i++) {
    if (i != k) {
      for (int j = 0; j < m; j++) {
        d[temp] = a[i] * b[j];
        temp++;
      }
    }
  }
  sort(d, d + m * n);
  cout << d[m * n - 1] << endl;
  return 0;
}
