#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int main() {
  long long a[maxn], b[maxn];
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
      cin >> b[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + m + 1);
    long long ans1 = a[1] * b[1], ans2 = a[n] * b[m], ans3 = a[1] * b[m],
              ans4 = a[n] * b[1];
    long long maxx = max(ans1, max(ans2, max(ans3, ans4)));
    if (maxx == ans1)
      cout << max(a[2] * b[1], max(ans2, max(a[2] * b[m], ans4))) << endl;
    else if (maxx == ans2)
      cout << max(a[n - 1] * b[m], max(ans1, max(ans3, a[n - 1] * b[1])))
           << endl;
    else if (maxx == ans3)
      cout << max(a[2] * b[1], max(ans2, max(a[2] * b[m], ans4))) << endl;
    else
      cout << max(ans1, max(a[n - 1] * b[m], max(ans3, a[n - 1] * b[1])))
           << endl;
  }
  return 0;
}
