#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  long long a[505], b[550];
  while (cin >> n >> m) {
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (long long i = 1; i <= m; i++) {
      cin >> b[i];
    }
    long long mxx = -1e18;
    for (long long i = 1; i <= n; i++) {
      for (long long k = 1; k <= m; k++) {
        long long tm = a[i] * b[k];
        mxx = max(mxx, tm);
      }
    }
    bool flag = 0;
    long long aP;
    for (long long i = 1; i <= n; i++) {
      for (long long k = 1; k <= m; k++) {
        long long tm = a[i] * b[k];
        if (flag == 0 && tm == mxx) {
          aP = i;
          flag = 1;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
    mxx = -1e18;
    for (long long i = 1; i <= n; i++) {
      if (i == aP) {
        continue;
      }
      for (long long k = 1; k <= m; k++) {
        long long tm = a[i] * b[k];
        mxx = max(mxx, tm);
      }
    }
    cout << mxx << endl;
  }
  return 0;
}
