#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 10;
long long a[N], b[N];
int n, m;
int main() {
  long long pre, now;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &now);
    if (i) a[i] = (now - pre) % mod;
    pre = now;
    printf("%lld ", a[i]);
  }
  puts("");
  for (int i = 0; i < m; i++) {
    scanf("%lld", &now);
    if (i) b[i] = (now - pre) % mod;
    pre = now;
    printf("%lld ", b[i]);
  }
  puts("");
  long long cnt = n - 1, sum1 = 0, sum2 = 0;
  int Left = 1, Right = n - 1;
  while (Left <= Right) {
    sum1 = (sum1 + a[Left] * cnt % mod) % mod;
    if (Right != Left) sum1 = (sum1 + a[Right] * cnt % mod) % mod;
    Right--;
    Left++;
  }
  cnt = m - 1;
  Left = 1;
  Right = m - 1;
  while (Left <= Right) {
    sum2 = (sum2 + b[Left] * cnt % mod) % mod;
    if (Right != Left) sum2 = (sum2 + b[Right] * cnt % mod) % mod;
    Right--;
    Left++;
  }
  printf("%lld\n", sum1 * sum2 % mod);
  return 0;
}
