#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const long long INF = 1LL << 60;
using vll = vector<long long>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pair<long long, long long> = pair<long long, long long>;
using vc = vector<char>;
using vvc = vector<vc>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vll x(n);
  vll 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());
  long long t = ((x[n - 1] - x[0]) % MOD) * ((y[m - 1] - y[0]) % MOD);
  t %= MOD;
  t *= modpow(2, (n + m - 4), MOD);
  cout << (t % MOD) << endl;
}
