#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... valT>
  static void call(const char* it, T val, valT... rest) {
    string var = "";
    for (; *it && *it != ','; it++)
      if (*it != ' ') var += *it;
    cerr << var << '=' << val << " ";
    call(++it, rest...);
  }
};
const int MAX = 200 + 10;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  int n, m;
  cin >> n >> m;
  long long A[n], B[m];
  for (int i = 0; i < (int)n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < (int)m; i++) {
    cin >> B[i];
  }
  sort(A, A + n);
  sort(B, B + m);
  long long ret1 = -1000000000000000002LL;
  long long ret2 = -1000000000000000002LL;
  for (int i = 0; i < (int)m; i++) {
    for (int j = 1; j < n; j++) {
      ret1 = max(ret1, A[j] * B[i]);
    }
  }
  for (int i = 0; i < (int)m; i++) {
    for (int j = 0; j < (int)n - 1; j++) {
      ret2 = max(ret2, A[j] * B[i]);
    }
  }
  cout << min(ret1, ret2);
}
