#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, m;
  cin >> n >> m;
  long long x[n], y[m];
  for (int i = 0; i < (n); i++) {
    cin >> x[i];
  }
  for (int i = 0; i < (m); i++) {
    cin >> y[i];
  }
  long long a, b, c = 0;
  a = ((x[n - 1] - x[0]) % 1000000007 * (n - 1)) % 1000000007;
  b = ((y[m - 1] - y[0]) % 1000000007 * (m - 1)) % 1000000007;
  long long d[9], e[9];
  for (int i = 0; i < (9); i++) {
    d[i] = a % 10;
    e[i] = b % 10;
    a = a / 10;
    b = b / 10;
  }
  for (int i = 0; i < (9); i++) {
    for (int j = 0; j < (9); j++) {
      c = (c + d[i] * e[j] * (int)pow(10, i) * (int)pow(10, j)) % 1000000007;
    }
  }
  cout << c << endl;
}
