#include <bits/stdc++.h>
using namespace std;
long long n, m, a[110], b[110];
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
    }
    long long maxm = -1e18, loc;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i] * b[j] > maxm) {
          maxm = a[i] * b[j];
          loc = i;
        }
      }
    }
    maxm = -1e18;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (i == loc) continue;
        if (a[i] * b[j] > maxm) {
          maxm = a[i] * b[j];
        }
      }
    }
    cout << maxm << endl;
  }
  return 0;
}
