#include <bits/stdc++.h>
using namespace std;
long long factorial(long n) {
  if (n == 0) {
    return 1;
  } else {
    return n * factorial(n - 1);
  }
}
int main(void) {
  long long n, m;
  cin >> n >> m;
  int x[100001], y[100001];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> y[i];
  }
  long long S;
  S = ((x[n - 1] - x[0]) * (y[m - 1] - y[0]));
  long long k;
  k = (n - 2) + (m - 2);
  k = factorial(k);
  long long ans = (k + 2) * S;
  cout << ans << endl;
  return 0;
}
