#include<bits/stdc++.h>
#define int long long
using namespace std;
int mod=1000000007;
#define r(i,n) for (int i=0; i < (n); i++)
main(){
	int h,w;
	cin>>h>>w;
	int a[h],b[w],c[h],d[w],H=0,W=0;
	r(i,h)cin>>a[i];
	r(i,w)cin>>b[i];
	int ta[h],tb[w];
	r(i,h-1)ta[i]=a[i+1]-a[i];
	r(i,w-1)tb[i]=b[i+1]-b[i];
	h--;
	w--;
	r(i,h)a[i]=ta[i],cout<<a[i]<<endl;
	r(i,w)b[i]=tb[i],cout<<b[i]<<endl;
	int hh=h-2;
	c[0]=c[h-1]=h;
	for(int i=1;i<h/2;i++){
		c[i]=c[h-1-i]=c[i-1]+hh;
		hh-=2;
	}
	if((h%2)&&h!=1)c[h/2]=c[(h/2)-1]+1;
	int ww=w-2;
	d[0]=d[h-1]=w;
	for(int i=1;i<w/2;i++){
		d[i]=d[w-1-i]=d[i-1]+ww;
		ww-=2;
	}
	if((w%2)&&w!=1)d[w/2]=d[(w/2)-1]+1;
	r(i,h)H=(H+(a[i]*c[i])%mod)%mod;
	r(i,w)W=(W+(b[i]*d[i])%mod)%mod;
	cout<<(H*W)%mod<<endl;
}
