#include <bits/stdc++.h>
long long a[114514];
long long b[114514];
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; i++) {
    cin >> b[i];
  }
  long long a2 = 1;
  long long b2 = 1;
  for (long long i = 0; i < n - 2; i++) {
    a2 = (a2 * 2) % 1000000007;
  }
  for (long long i = 0; i < m - 2; i++) {
    b2 = (b2 * 2) % 1000000007;
  }
  cout << (((a[n - 1] - a[0]) % 1000000007 * (b[m - 1] - b[0]) % 1000000007) %
           1000000007 * (a2 * b2) % 1000000007) %
              1000000007
       << endl;
}
