#include <bits/stdc++.h>
using namespace std;
void init() {}
int main() {
  init();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int a[n], b[m];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < m; i++) cin >> b[i];
  long long int mn = 9223372036854775807;
  for (long long int i = 0; i < n; i++) {
    long long int mx = -9223372036854775807;
    for (long long int k = 0; k < n; k++) {
      if (k == i) continue;
      for (long long int j = 0; j < m; j++) mx = max(mx, a[k] * b[j]);
    }
    mn = min(mn, mx);
  }
  cout << mn;
  return 0;
}
