#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
using P = pair<long long, long long>;
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> x(n), y(m);
  for (long long i = 0; i < n; i++) cin >> x[i];
  for (long long i = 0; i < m; i++) cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  vector<tuple<P, P>> v;
  function<void(long long, long long, long long, long long)> rec =
      [&](long long xl, long long xr, long long yl, long long yr) {
        if (xl >= xr || yl >= yr) return;
        for (long long i = xl + 1; i <= xr - 1; i++) {
          rec(xl, i, yl, yr);
          rec(i, xr, yl, yr);
        }
        for (long long i = yl + 1; i <= yr - 1; i++) {
          rec(xl, xr, i, yr);
          rec(xl, xr, yl, i);
        }
        v.push_back(make_tuple(P(xl, xr), P(yl, yr)));
        return;
      };
  rec(0, n - 1, 0, m - 1);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  long long ans = 0;
  for (auto p : v) {
    long long xl = get<0>(p).first;
    long long xr = get<0>(p).second;
    long long yl = get<1>(p).first;
    long long yr = get<1>(p).second;
    long long res = (x[xr] - x[xl]) * (y[yr] - y[yl]) % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
  return 0;
}
