#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint dfs(vector<int>& x, vector<int>& y, int ix0, int ixm, int iy0, int iym) {
  static map<tuple<int, int, int, int>, mint> m;
  static map<tuple<int, int, int, int>, bool> ck;
  mint ret;
  if (m.count(make_tuple(ix0, ixm, iy0, iym)) == 0) {
    ret = (ll)(x.at(ixm) - x.at(ix0)) * (ll)(y.at(iym) - y.at(iy0));
    m[make_tuple(ix0, ixm, iy0, iym)] = ret;
    ck[make_tuple(ix0, ixm, iy0, iym)] = false;
  } else {
    if (ck[make_tuple(ix0, ixm, iy0, iym)] == false)
      return m[make_tuple(ix0, ixm, iy0, iym)];
    else
      ret = 0;
  }
  for (int i = (int)(ix0 + 1); i < (int)(ixm); i++) {
    ret += dfs(x, y, ix0, i, iy0, iym);
    ret += dfs(x, y, i, ixm, iy0, iym);
  }
  for (int i = (int)(iy0 + 1); i < (int)(iym); i++) {
    ret += dfs(x, y, ix0, ixm, iy0, i);
    ret += dfs(x, y, ix0, ixm, i, iym);
  }
  m[make_tuple(ix0, ixm, iy0, iym)] = ret;
  ck[make_tuple(ix0, ixm, iy0, iym)] = true;
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n);
  for (int snip_i = 0; snip_i < (int)(n); snip_i++) cin >> x.at(snip_i);
  vector<int> y(m);
  for (int snip_i = 0; snip_i < (int)(m); snip_i++) cin >> y.at(snip_i);
  mint ans = dfs(x, y, 0, x.size() - 1, 0, y.size() - 1);
  cout << ans.x << endl;
  return 0;
}
