#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

namespace mymod {
    constexpr ll modulus = 1000000007LL;

    ll add(ll a, ll b);

    ll sub(ll a, ll b);

    ll mul(ll a, ll b);

    ll power(ll a, ll b);

    ll div(ll a, ll b);
}

ll mymod::add(ll a, ll b){return (a + b) % modulus;}
ll mymod::sub(ll a, ll b){return (a + modulus - b) % modulus;}
ll mymod::mul(ll a, ll b){return ((a % modulus) * (b % modulus)) % modulus;}
ll mymod::power(ll a, ll b){
    if (b == 0) return 1;
    else if (b == 1) return a % modulus;
    else if (b % 2 == 0){ll p = power(a, b / 2); return p * p % modulus;}
    else return a * power(a, b-1) % modulus;
}
ll mymod::div(ll a, ll b){return mul(a, power(b, modulus-2));}


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> xs(n, 0), ys(m, 0);
    for (auto && i: boost::irange(0LL, n)){
        cin >> xs.at(i);
    }
    for (auto && i: boost::irange(0LL, m)){
        cin >> ys.at(i);
    }
    ll s = mymod::mul((*max_element(xs.begin(), xs.end())-*min_element(xs.begin(), xs.end())), (*max_element(ys.begin(), ys.end()) - * min_element(ys.begin(), ys.end())));
    cout << mymod::mul(mymod::power(2, n+m-4), s);
    return 0;
}