#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long sn[60], sm[60];
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> sn[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> sm[i];
  }
  int idx = 0;
  long long max = sn[0] * sm[0];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (sn[i] * sm[j] > max) {
        max = sn[i] * sm[j];
        idx = i;
      }
    }
  }
  if (idx == 0)
    max = sn[1] * sm[0];
  else
    max = sn[0] * sm[0];
  for (int i = 0; i < n; ++i) {
    if (i == idx) continue;
    for (int j = 0; j < m; ++j) {
      if (sn[i] * sm[j] > max) {
        max = sn[i] * sm[j];
      }
    }
  }
  cout << max << endl;
  return 0;
}
