#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds; //  order of key(keys strictly less than)  // find_by_order
//typedef tree<long long,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
//IF WA CHECK FOR : -
// 1 > EDGE CASES LIKE N=1 , N=0
// 2 > SIGNED INTEGER OVERFLOW IN MOD
// 3 > CHECK THE CODE FOR LOGICAL ERRORS AND SEG FAULTS
// 4 > READ THE PS ONCE AGAIN , if having double diff less than 1e-8 is same.
// 5 > You Have got AC .
#define ll long long
#define NUM (ll)998244353
#define inf (long long)(2e18)
#define ff first
#define ss second
#define f(i,a,b) for(ll i=a;(i)<long(b);(i)++)
#define fr(i,a,b) for(ll i=a;(i)>=(long long)(b);(i)--)
#define it(b)  for(auto &it:(b))
#define pb push_back
#define mp make_pair
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
ll binpow( ll base , ll ex,ll mod=NUM) {
    ll ans = 1;base = base % mod;
    if(base==0){
        return 0;
    }
    while (ex > 0) {
        if (ex % 2 == 1) {
            ans = (ans * base) % mod;
        }
        base = (base * base) % mod;
        ex = ex / 2;
    }
    return ans;
}
void read(vll &arr,ll n) {
    if (arr.size() != n) { arr.assign(n, 0); }for (int i = 0; i < n; i++)cin >> arr[i];
}
inline ll min(ll a,ll b){
    if(a>b)return b;return a;
}
inline ll max(ll a, ll b){
    if(a>b)return a;return b;
}
inline ll dif(ll a,ll b) {
    if (a > b)return a - b;return b - a;
}
long long gcd(long long a,long long b) {
    if (b == 0)return a;return gcd(b, a % b);
}
long long lcm(long long a,long long b) {
    long long k = gcd(a, b);
    return (a * b) / k;
}
void solve() {
    ll n,m;
    cin>>n>>m;
    vector<ll> a;read(a,n+1);
    vector<ll>c(n+m+1);read(c,n+m+1);
    vector<ll> b(m+1);
    b[0]=c[0]/a[0];
    f(j,1,m+1){
        ll curr = c[j];
        f(k,0,j){
            if(j-k>=a.size() or k>=b.size()){
                continue;
            }
            curr-=(b[k]*a[j-k]);
        }
        b[j]=curr/a[0];
    }
    f(i,0,m){
        cout<<b[i]<<" ";
    }
    cout<<b[m];
    cout<<"\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << showpoint;
    cout << setprecision(12);
    long long test_m = 1;
    int k=1;
    //cin >> test_m;
    //WE WILL WIN .
    while (test_m--) {
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
}