#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  vector<long long> v(a), v2(b);
  set<long long> stt;
  for (int i = 0; i < a; ++i) cin >> v[i];
  for (int i = 0; i < b; ++i) cin >> v2[i];
  for (int i = 0; i < a; ++i) {
    set<long long> sst;
    for (int j = 0; j < b; ++j) {
      for (int c = 0; c < a; ++c) {
        if (i != c) {
          long long res = v2[j] * v[c];
          sst.insert(res);
        }
      }
    }
    stt.insert(*(--sst.end()));
  }
  cout << (*stt.begin()) << endl;
}
