#include <bits/stdc++.h>
using namespace std;
long long n, m, minx = 1000000001, maxx = -1000000001, miny = 1000000001,
                maxy = -1000000001, ans;
int main() {
  long long i, j, u, v;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> u;
    minx = min(minx, u);
    maxx = max(maxx, u);
  }
  for (i = 1; i <= m; i++) {
    cin >> u;
    miny = min(miny, u);
    maxy = max(maxy, u);
  }
  ans =
      ((maxx - minx) % 1000000007) * ((maxy - miny) % 1000000007) % 1000000007;
  ans = (((ans * (n - 1)) % 1000000007) * (m - 1)) % 1000000007;
  cout << ans << endl;
  return (0);
}
