#pragma GCC optimize("O3") #include #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair #define pii pair #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; inline int topbit(unsigned long long x){ return x?63-__builtin_clzll(x):-1; } inline int popcount(unsigned long long x){ return __builtin_popcountll(x); } inline int parity(unsigned long long x){//popcount%2 return __builtin_parity(x); } template inline bool chmax(T& a,T b){if(a inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} const ll INF=1e9+7; int n; int m=1; vector> f,g; struct FastFourierTransform{ static void dft(vector>& func, int inverse){ int sz=func.size(); if(sz==1) return ; vector> veca, vecb; rep(i,sz/2){ veca.push_back(func[2*i]); vecb.push_back(func[2*i+1]); } dft(veca, inverse); dft(vecb, inverse); complex now=1,zeta=polar(1.0, inverse*2.0*acos(-1)/sz); rep(i,sz){ func[i]=veca[i%(sz/2)]+now*vecb[i%(sz/2)]; now*=zeta; } } template static vector multiply(vector f,vector g){ vector> nf, ng; int sz=1; while(sz res; rep(i,sz)res.push_back(nf[i].real()/sz); return res; } }; int main(){ ios; ll n,q; cin >> n >> q; vector a(n); vector r(q); vector ans(n); vector> cnt(1001,vector(n)),sum(1001,vector(n)); rep(i,n){ cin >> a[i]; cnt[a[i]][i]=1; } rep(i,q){ cin >> r[i]; } while(m<2*n || m<2*q) m*=2; f.resize(m); g.resize(m); for(ll i=0;i<=1000;i++){ FastFourierTransform FFT; rep(j,n){ f[j]=cnt[i][j]; } rep(j,q){ g[(n-r[j])%n]+=1; } FFT.dft(f,1); FFT.dft(g,1); rep(j,m){ f[j]*=g[j]; } FFT.dft(f,-1); rep(j,2*n){ sum[i][j%n]+=(ll)(f[j].real()/m+0.1); } rep(j,m){ f[j]=0; g[j]=0; } } for(ll i=0;i<=1000;i++){ rep(j,n){ ans[j]+=sum[i][j]*i; } } rep(i,n){ if(i) cout << " "; cout << ans[i]; } cout << endl; return 0; }