#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5;
long long k, ans;
int n, m;
set<int> a;
set<int> b;
long long x[MaxN + 5], y[MaxN + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &x[i]);
    a.insert(x[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &y[i]);
    b.insert(y[i]);
  }
  int len1 = a.size() - 1;
  int len2 = b.size() - 1;
  sort(x + 1, x + n + 1);
  sort(y + 1, y + n + 1);
  k = abs(x[n] - x[1]) * abs(y[m] - y[1]);
  ans = k * len1 * len2;
  printf("%lld\n", ans);
  return 0;
}
