#include <bits/stdc++.h>
using namespace std;
long long int a[52];
long long int b[52];
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, m;
  long long x, mx = -1e18;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int j = 1; j <= m; j++) {
    cin >> b[j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mx < a[i] * b[j]) {
        mx = a[i] * b[j];
        x = i;
      }
    }
  }
  mx = -1e18;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (i != x) {
        mx = max(mx, a[i] * b[j]);
      }
    }
  }
  cout << mx;
  return 0;
}
