#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> x(n), y(m);
  for (int i = 0; i < n; ++i) cin >> x.at(i);
  for (int i = 0; i < m; ++i) cin >> y.at(i);
  cout << (((((x.back() - x.front()) % mod) * ((y.back() - y.front()) % mod)) %
            mod) *
           ((n - 1) * (m - 1) % mod)) %
              mod
       << endl;
  return 0;
}
