#include <bits/stdc++.h>
using namespace std;
long long maxi(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  int n, m;
  cin >> n >> m;
  int ap, an, bp, bn;
  ap = an = bp = bn = 0;
  long long ar[n];
  long long br[m];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] < 0) {
      an = 1;
    } else {
      ap = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> br[i];
    if (br[i] < 0) {
      bn = 1;
    } else {
      bp = 1;
    }
  }
  int flag = 0;
  if (ap == 1 && bp == 1 && an == 0 && bn == 0) {
    flag = 1;
    long long max = -1000000000000;
    long long secmax = -1000000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] > max) {
        secmax = max;
        max = ar[i];
      } else if (ar[i] > secmax) {
        secmax = ar[i];
      }
    }
    long long max1 = -1000000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] > max1) {
        max1 = br[i];
      }
    }
    cout << secmax * max1;
  }
  if (ap == 0 && bp == 0 && an == 1 && bn == 1) {
    flag = 1;
    long long min = 10000000000000;
    long long secmin = 100000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] < min) {
        secmin = min;
        min = ar[i];
      } else if (ar[i] < secmin) {
        secmin = ar[i];
      }
    }
    long long min1 = 100000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] < min1) {
        min1 = br[i];
      }
    }
    cout << secmin * min1;
  }
  if (ap == 0 && bp == 1 && an == 1 && bn == 0) {
    flag = 1;
    long long max = -1000000000000;
    long long secmax = -1000000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] > max) {
        secmax = max;
        max = ar[i];
      } else if (ar[i] > secmax) {
        secmax = ar[i];
      }
    }
    long long min1 = 1000000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] < min1) {
        min1 = br[i];
      }
    }
    cout << secmax * min1;
  }
  if (ap == 1 && bp == 0 && an == 0 && bn == 1) {
    flag = 1;
    long long min = 10000000000;
    long long secmin = 1000000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] < min) {
        secmin = min;
        min = ar[i];
      } else if (ar[i] < secmin) {
        secmin = ar[i];
      }
    }
    long long max1 = -100000000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] > max1) {
        max1 = br[i];
      }
    }
    cout << secmin * max1;
  }
  if (flag == 0) {
    long long max = -1000000000000;
    long long secmax = -1000000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] > max) {
        secmax = max;
        max = ar[i];
      } else if (ar[i] > secmax) {
        secmax = ar[i];
      }
    }
    long long max1 = -1000000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] > max1) {
        max1 = br[i];
      }
    }
    long long min = 100000000000;
    long long secmin = 100000000000;
    for (int i = 0; i < n; i++) {
      if (ar[i] < min) {
        secmin = min;
        min = ar[i];
      } else if (ar[i] < secmin) {
        secmin = ar[i];
      }
    }
    long long min1 = 10000000000;
    for (int i = 0; i < m; i++) {
      if (br[i] < min1) {
        min1 = br[i];
      }
    }
    if ((min * min1) > (max * max1)) {
      cout << maxi((secmin * min1), max * max1);
    } else {
      cout << maxi((secmax * max1), min * min1);
    }
  }
  return 0;
}
