#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, a[55], b[55];
  while (cin >> n >> m) {
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 1; i <= m; i++) cin >> b[i];
    long long mx = -1000000000000000000;
    long long ind;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        long long r = a[i] * b[j];
        if (r > mx) {
          mx = r;
          ind = i;
        }
      }
    }
    mx = -1000000000000000000;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (i != ind) {
          long long r = a[i] * b[j];
          if (r > mx) {
            mx = r;
          }
        }
      }
    }
    cout << mx << endl;
  }
}
