#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
int n, m;
const int maxn = 55;
long long ar_n[maxn];
long long ar_m[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  while (cin >> n >> m) {
    memset(ar_n, 0, sizeof(ar_n));
    memset(ar_m, 0, sizeof(ar_m));
    for (int i = 0; i < n; ++i) {
      cin >> ar_n[i];
    }
    for (int i = 0; i < m; ++i) {
      cin >> ar_m[i];
    }
    long long suit1 = LINF;
    long long suit2 = -LINF;
    for (int i = 0; i < n; ++i) {
      suit2 = -LINF;
      for (int j = 0; j < n; ++j) {
        if (j != i) {
          for (int k = 0; k < m; ++k) {
            suit2 = max(suit2, ar_n[j] * ar_m[k]);
          }
        }
      }
      suit1 = min(suit2, suit1);
    }
    cout << suit1 << "\n";
  }
  return 0;
}
