// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = false;

// --------------------------------------------------------------------------------------

#define PRIME7_SHORT 10007UL
#define PRIME9_SHORT 10009UL
#define PRIME7 1000000007UL


// DECLARATIONS
template <typename T> T ipow(T base, T exp);

template <typename T> T griddist(T x, T y, T s, T t);
template <typename T> T griddist(std::pair<T, T> one, std::pair<T, T> two);
template <typename T> T griddist(std::tuple<T, T> one, std::tuple<T, T> two);

template <typename T> T sqeucldist(T x, T y, T s, T t);
template <typename T> T sqeucldist(std::pair<T, T> one, std::pair<T, T> two);
template <typename T> T sqeucldist(std::tuple<T, T> one, std::tuple<T, T> two);

struct F;
template <class CharT, class Traits>
auto& operator<<(std::basic_ostream<CharT, Traits>& os, const F value);


// IMPLEMENTATIONS
template <typename T> T ipow(T base, T exp) {
    T result = static_cast<T>(1);
    // Maybe add inverse functionality
    // if (exp < 0) {
    //     exp = -exp;
    //     // Doesn't really work since T integral
    //     base = 1./base;
    // }
    while (exp) {
        if (exp & 1) result *= base;
        exp >>= 1;
        base *= base;
    }
    return result;
}


template <typename T> T griddist(T x, T y, T s, T t)
    { return std::abs(x-s) + std::abs(y-t); }

template <typename T> T griddist(std::pair<T, T> one, std::pair<T, T> two)
    { return std::abs(one.first - two.first) + std::abs(one.second - two.second); }

template <typename T> T griddist(std::tuple<T, T> one, std::tuple<T, T> two)
    { return std::abs(std::get<0>(one) - std::get<0>(two)) + std::abs(std::get<1>(one) - std::get<1>(two)); }

template <typename T> T sqeucldist(T x, T y, T s, T t)
    { T a = x-s; T b = y-t; return a*a+b*b; }

template <typename T> T sqeucldist(std::pair<T, T> one, std::pair<T, T> two)
    { T a = one.first - two.first; T b = one.second - two.second; return a*a+b*b; }

template <typename T> T sqeucldist(std::tuple<T, T> one, std::tuple<T, T> two)
    { T a = std::get<0>(one) - std::get<0>(two); T b = std::get<1>(one) - std::get<1>(two); return a*a+b*b; }

struct F
{
    F() : m_mod(PRIME7), m_value(0UL) {}
    F(unsigned long long value) : m_mod(PRIME7), m_value(value%m_mod) {}
    F(unsigned long long value, unsigned long long mod) : m_mod(mod), m_value(value%m_mod) {}
    F operator+(F other) const
        { return {m_value + other.m_value, m_mod}; }
    F operator-(F other) const
        { return {m_value - other.m_value + m_mod, m_mod}; }
    F operator*(F other) const
        { return {m_value * other.m_value, m_mod}; }

    unsigned long long operator()() const { return (unsigned long long) m_value; }

    unsigned long long m_mod;
    unsigned long long m_value;
};

template <class CharT, class Traits>
auto& operator<<(std::basic_ostream<CharT, Traits>& os, const F value)
    { return (os << value.m_value); }

using namespace std;

int main(void) {
    size_t n, m;
    cin >> n >> m;

    std::vector<long> x;
    std::vector<long> y;
    for (size_t i = 0; i < n; ++i) {
        long xx;
        cin >> xx;
        x.push_back(xx);
    }
    for (size_t i = 0; i < m; ++i) {
        long yy;
        cin >> yy;
        y.push_back(yy);
    }

    --n;
    --m;

    F xa;
    F ya;

    for (size_t i = 0; i < n; ++i) {
        size_t lef, rig;
        lef = i + 1;
        rig = n - i;
        F mult{lef * rig};
        F xxx{x[i+1] - x[i]};
        xa = xa + (mult * xxx);
    }

    for (size_t j = 0; j < m; ++j) {
        size_t up, dow;
        up = m - j;
        dow = j + 1;
        F mult{up * dow};
        F yyy{y[j+1] - y[j]};
        ya = ya + (mult * yyy);
    }

    F area = xa * ya;

    cout << area() << '\n';
    return 0;
}


Measured memory_bytes: 2548