#include <bits/stdc++.h>
using namespace std;

int main(){
    long k, n, m, p, c;
    cin >> k >> n >> m;
    p = m;
    long a[k], b[k] = {};
    for(int i = 0; i < k; i++) cin >> a[i];
    priority_queue<pair<long, long>, vector<pair<long, long>>, less<pair<long, long>>> q;
    for(int i = 0; i < k; i++){
        b[i] += a[i] * m / n;
        p -= a[i] * m / n;
        q.push(make_pair(m * a[i] - n * b[i], i));
    }
    while(p > 0){
        c = q.top().second;
        q.pop();
        b[c]++, p--;
        q.push(make_pair(m * a[c] - n * b[c], c));
    }
    for(int i = 0; i < k; i++){
        cout << b[i];
        if(i == k - 1) cout << endl;
        else cout << " ";
    }
}
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define maxn 300005
#define inf 1e9
#define ins insert
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m,ct[maxn];
ll dp[20][maxn];

int main()
{
	n=read(); m=read(); int ed=(1<<n)-1;
	rep(i,0,ed) ct[i]=ct[i>>1]+(i&1); dp[0][0]=1;
	rep(i,1,m)
	{
		int x=read(),y=read(),z=read();
		rep(s,0,ed) if(ct[s&((1<<y)-1)]>z) dp[x][s]=-1;
	}
	rep(i,1,n)
	{
		rep(s,0,ed)
		{
			if(dp[i][s]==-1) continue;
			rep(j,1,n) if((s&(1<<(j-1)))&&dp[i-1][s^(1<<(j-1))]!=-1)
				dp[i][s]+=dp[i-1][s^(1<<(j-1))];
		}
	}
	cout<<dp[n][ed];
	return 0;
}