#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
long long MOD = 1e9 + 7;
int main() {
  int m, n;
  cin >> m >> n;
  long long temp;
  long long minX = 1e18, maxX = -1e18;
  for (int i = 0; i < m; ++i) {
    cin >> temp;
    minX = min(minX, temp);
    maxX = max(maxX, temp);
  }
  long long minY = 1e18, maxY = -1e18;
  for (int j = 0; j < n; ++j) {
    cin >> temp;
    minY = min(minY, temp);
    maxY = max(maxY, temp);
  }
  long long res =
      (((maxX - minX) * (maxY - minY)) % MOD) * ((m - 1) * (n - 1) % MOD) % MOD;
  cout << res << endl;
  return 0;
}
