#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k, n, m;
    cin >> k >> n >> m;
    int a[k], b[k];
    vector<pair<int,int>> v;
    int rem = m;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        b[i] = (m*a[i])/n;
        rem -= b[i];
        v.push_back({m*a[i]-b[i]*n,i});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for (int i = 0; i < rem; i++) b[v[i].second]++;
    for (int i = 0; i < k; i++) cout << b[i] << ' ';
    cout << '\n';
}
/**
    template for testing/using the algorithms
    import(copy-paste the methods ;v) algorithm/s and use here
**/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;


///------------------- algorithm function/s to be placed here start -------------------///

string s[3];
unsigned long long N[3][10+5], n[3];

vector<char> chars;
vector<bool> isFirst;

void insertNumWhereChar(long long num, char c){

    for(int i=0;i<3;i++){

        for(int j=0;j<s[i].size();j++){

            if(s[i][j] == c) N[i][j] = num;
        }
    }
}

bool isN1PlusN2EqualsN3(){

    for(int i=0;i<3;i++){

        n[i] = 0;

        for(int j=0;j<s[i].size();j++){

            n[i] = n[i]*10 + N[i][j];
        }
    }

    int len[3]; bool lenSame = true;
    for(int i=0;i<3;i++){

        long long x = n[i]; len[i] = 0;

        while(x){

            x/=10;
            len[i]++;
        }

        lenSame = lenSame && (len[i]==s[i].size());
    }

    return (n[0]+n[1] == n[2]) && lenSame;
}

bool findd( int i, bool taken[10]){


    if(i==chars.size()) {

        return isN1PlusN2EqualsN3();
    }

    int start = 0;

    if(isFirst[i]) start++;

    bool found = false;

    for(int ii=start;ii<10;ii++){

        if(taken[ii]) continue;

        taken[ii] = true;
        insertNumWhereChar(ii, chars[i]);

        found = found || findd(i+1, taken);
        if(found) return true;

        //removeNumWhereChar(chars[i]);
        taken[ii] = false;
    }

    return found;
}

///-------------------- algorithm function/s to be placed here end --------------------///


void exec(int T){
// execute the algorithm

    string s1[3]; cin>>s[0]>>s[1]>>s[2];

    map<char, bool> uniq_chars;
    for(int i=0;i<3;i++){

        for(int j=0;j<s[i].size();j++) uniq_chars[s[i][j]] = (j==0);
    }

    if(uniq_chars.size()>10){

        cout<<"UNSOLVABLE\n";
        return;
    }

    chars.clear();
    isFirst.clear();
    for(auto i = uniq_chars.begin();i!=uniq_chars.end();i++){

        chars.push_back(i->first);
        isFirst.push_back(i->second);
    }

    bool taken[10];
    for(int i=0;i<10;i++) taken[i] = false;
    if(findd(0, taken)) cout<<n[0]<<"\n"<<n[1]<<"\n"<<n[2]<<"\n";
    else cout<<"UNSOLVABLE\n";

}


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int t=1;

    //cin>>t;

    for(int T=1;T<=t;T++){

        exec(T);

    }

    return 0;
}
