#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  vector<int> y(m);
  for (int i = 0; i < n; ++i) {
    cin >> y[i];
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  cout << (x[n - 1] - x[0]) * (y[m - 1] - y[0]) * (n - 1) * (m - 1) << endl;
  return 0;
}
