#include <bits/stdc++.h>
using namespace std;
long long lsx[100005], lsy[100005];
long long cntx[100005] = {0}, cnty[100005] = {0};
long long n, m, x = 0, y = 0, ans;
long long minx = 10000000000, miny = 10000000000, maxx = 0, maxy = 0;
int main() {
  long long i, j;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    cin >> lsx[i];
    if (i != 0) {
      cntx[i] = cntx[i - 1];
      if (lsx[i] == lsx[i - 1]) ++cntx[i];
    }
  }
  for (j = 0; j < m; ++j) {
    cin >> lsy[j];
    if (j != 0) {
      cnty[j] = cnty[j - 1];
      if (lsy[j] == lsy[j - 1]) ++cnty[j];
    }
  }
  minx = lsx[0];
  for (i = 1; i < n; ++i) {
    maxx = lsx[i];
    if (maxx == minx) continue;
    x += ((maxx - minx) * (i - cntx[i]) % 1000000007 *
          (n - i - (cntx[n - 1] - cntx[i - 1]))) %
         1000000007;
    x %= 1000000007;
    minx = maxx;
  }
  miny = lsy[0];
  for (i = 1; i < m; ++i) {
    maxy = lsy[i];
    if (maxy == miny) continue;
    y += ((maxy - miny) * (i - cnty[i]) % 1000000007 *
          (m - i - (cnty[m - 1] - cnty[i - 1]))) %
         1000000007;
    miny = maxy;
  }
  cout << (x * y) % 1000000007 << endl;
  return 0;
}
