#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> xx(n), yy(m);
  for (int i = 0; i < int(n); i++) cin >> xx[i];
  for (int i = 0; i < int(m); i++) cin >> yy[i];
  ll S = (((xx[n - 1] - xx[0]) % MOD) * ((yy[n - 1] - yy[0]) % MOD)) % MOD;
  ll coe = 1;
  for (int i = 0; i < int(n - 2); i++) {
    coe *= 2;
    coe %= MOD;
  }
  for (int i = 0; i < int(m - 2); i++) {
    coe *= 2;
    coe %= MOD;
  }
  cout << (coe * S) % MOD << endl;
  return 0;
}
