#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<long long> row;
  vector<long long> row2;
  long long aux;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    row.push_back(aux);
  }
  for (int i = 0; i < m; i++) {
    cin >> aux;
    row2.push_back(aux);
  }
  long long maxx = -INF;
  int pos = 0;
  for (int i = 0; i < row.size(); i++)
    for (int j = 0; j < row2.size(); j++) {
      if (maxx < row[i] * row2[j]) {
        maxx = row[i] * row2[j];
        pos = i;
      }
    }
  row.erase(row.begin() + pos);
  maxx = -INF;
  for (int i = 0; i < row.size(); i++)
    for (int j = 0; j < row2.size(); j++) maxx = max(maxx, row[i] * row2[j]);
  cout << maxx << endl;
  return 0;
}
