#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int n, m;
long long x[100000 + 5];
long long y[100000 + 5];
long long xx[100000 + 5];
long long yy[100000 + 5];
long long qx[100000 + 5];
long long hx[100000 + 5];
long long qy[100000 + 5];
long long hy[100000 + 5];
long long Y[100000 + 5];
long long X[100000 + 5];
void fx() {
  for (int i = 1; i <= n; ++i) {
    x[i] = xx[i + 1] - xx[i];
  }
  qx[0] = 0;
  for (int i = 1; i <= n; ++i) {
    qx[i] = qx[i - 1] + x[i];
  }
  hx[n + 1] = 0;
  for (int i = n; i >= 1; --i) {
    hx[i] = hx[i + 1] + x[i];
  }
  X[n] = qx[n];
  for (int i = 1; i <= n - 1; ++i) {
    X[i] = (X[n] - qx[i] + X[n] - hx[i]);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%lld ", X[i]);
  }
  printf("\n");
}
void fy() {
  qy[0] = 0;
  for (int i = 1; i <= m - 1; ++i) {
    qy[i] = qy[i - 1] + y[i];
  }
  hy[m + 1] = 0;
  for (int i = m; i >= 1; --i) {
    hy[i] = hy[i + 1] + y[i];
  }
  Y[m] = qy[m];
  for (int i = n; i >= 1; --i) {
    Y[i] = (m - i) * ((Y[m] - qy[m - i]) + (Y[m] - hy[m - i]));
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%lld", &xx[i]);
    for (int i = 1; i <= m; ++i) scanf("%lld", &yy[i]);
    for (int i = 1; i <= m - 1; ++i) {
      y[i] = yy[i + 1] - yy[i];
    }
    n--;
    m--;
    fx();
    fy();
    long long sumy = 0;
    long long sumx = 0;
    for (int i = 1; i <= n; ++i) sumx += X[i];
    for (int i = 1; i <= m; ++i) sumy += Y[i];
    printf("%lld %lld \n", sumx, sumy);
    printf("%lld\n", sumy * sumx);
  }
  return 0;
}
