#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>k;
        cin>>n>>m;
        ll a[k];
        fo(i,k)cin>>a[i];
        ll sum=0;
        pll p[k];
        fo(i,k){
            p[i]= mp((m*a[i])%n , i);
            sum+= (m*a[i])%n;
        }
        //cout<<sum<<endl;
        sort(p,p+k);
        ll val = sum/n;
        //cout<<val;
        ll ans[k];
        fo(i, k){
            ll  j = p[i].se;
            //cout<<j<<endl;
            //cout<<a[j]<<endl;
            if(i<k-val)ans[j]= m*a[j]/n;
            else ans[j] =m*a[j]/n   + 1;
        }
        fo(i,k)cout<<ans[i]<<" ";






        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

#include<bits/stdc++.h>
#define int long long int
const int M = 998244353;
const int mod = 1e9+7; 
const int inf = 1e18+5;
using namespace std;
#define debug() for(int l=0;l<50;l++){}
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
int bs(int arr[], int l, int r, int x){
	int mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
int power(int x,int y,int p){
	int res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
const int max1=500001;
pair<int,int>st[4*max1];
int arr[max1],arr1[max1];
void buildtree(int si,int ss,int se){
	if(ss==se){
        st[si].first=arr1[ss];
        st[si].second=arr1[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	if(arr1[mid]>arr1[mid+1]) st[si].first=st[2*si].first+st[2*si+1].first;
    else st[si].second=st[2*si].second+st[2*si+1].second;
	
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return inf;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
int geteven(int si,int ss,int se,int qs,int qe){
	if(ss>qe || se<qs) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].second;
	int mid=ss+(se-ss)/2;
	int l=geteven(2*si,ss,mid,qs,qe);
	int r=geteven(2*si+1,mid+1,se,qs,qe);
	return l+r;
}
int getodd(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=getodd(2*si,ss,mid,qs,qe);
	int r=getodd(2*si+1,mid+1,se,qs,qe);
	return l+r;
}

void update(int si,int ss,int se,int qi,int newval){
	if(ss==se){
        if(arr[ss]%2==1) st[si]={0,1};
        else st[si]={1,0};
		arr[ss]=newval;
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi,newval);
	else update(2*si+1,mid+1,se,qi,newval);
	st[si].first=st[2*si].first+st[2*si+1].first;
    st[si].second=st[2*si].second+st[2*si+1].second;
}

int mm(int a, int b, int m){
    int res = 0;
    a %= m; 
    while (b){  
        if (b & 1) 
            res = (res + a) % m; 
        a = (2 * a) % m; 
        b >>= 1; 
    }
    return res; 
} 
  
string solve(){
	string s;
	cin>>s;
	int l=s.length();
	if(l==1){
		if(s[0]=='8') return "Yes\n";
	}
	else if(l==2){
		int val=(s[0]-'0')*10 + s[1];
		int val2=(s[1]-'0')*10 + s[0];
		if(!(val%8) || !(val2%8)) return "Yes\n";
	}
	else{
		int ch[10]={0};
		for(auto i:s) ch[i-'0']++;
		for(int i=104;i<1000;i+=8){
			int f=0,ch1[10]={0};
			string str=to_string(i);
			for(auto j:str) ch1[j-'0']++;
			for(int j=0;j<10;j++)
				if(ch[j]<ch1[j]) f=1;
			if(!f) return "Yes\n";
		}
	}
	return "No\n";
}
signed main(){
	fast;
	int t=1;
	//cin>>t;
	while(t--) cout<<solve();
	return 0;
}
