#include <bits/stdc++.h>
using namespace std;
long long ytable[100001];
long long xtable[100001];
int main(void) {
  long long n, m;
  cin >> n >> m;
  vector<long long> xs;
  vector<long long> ys;
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    xs.push_back(t);
  }
  for (long long i = 0; i < m; i++) {
    long long t;
    cin >> t;
    ys.push_back(t);
  }
  xtable[0] = xs[1] - xs[0];
  for (long long i = 1; i < n - 1; i++) {
    xtable[i] =
        (xtable[0] + ((xs[i + 1] - xs[i]) * 2) % 1000000007) % 1000000007;
  }
  for (long long i = 0; i < n - 1; i++) {
    cout << xtable[i] << " ";
  }
  cout << endl;
  ytable[0] = ys[1] - ys[0];
  for (long long i = 1; i < m - 1; i++) {
    ytable[i] =
        (ytable[0] + ((ys[i + 1] - ys[i]) * 2) % 1000000007) % 1000000007;
  }
  long long sum = 0;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < m - 1; j++) {
      sum += xtable[i] * ytable[j] % 1000000007;
    }
  }
  cout << sum << endl;
  return 0;
}
