#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> a(n + 5), b(m + 5);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < m; j++) cin >> b[j];
  vector<long long int> ans;
  long long int mx = a[0] * b[0];
  int kx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mx < a[i] * b[j]) {
        mx = a[i] * b[j];
        kx = i;
      }
    }
  }
  int flag = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m && i != kx; j++) {
      if (flag || mx < a[i] * b[j]) {
        mx = a[i] * b[j];
        flag = 0;
      }
    }
  }
  cout << mx << endl;
  return 0;
}
