#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long k;
    cin >> n >> k; 
    vector<long long> a(n);
    for(auto &x: a) cin >> x;
    vector<int> spf(k + 1, 0);
    for(long long p = 2; p <= k; ++p){
        if(spf[p] == 0){
            spf[p] = p;
            if(p * p > k) continue;
            for(long long multiple = p * p; multiple <= k; multiple += p){
                if(spf[multiple] == 0){
                    spf[multiple] = p;
                }
            }
        }
    }
    vector<long long> freq(k + 1, 0);
    for(long long x = 2; x <= k; ++x){
        freq[spf[x]]++;
    }
    for(int i = 0; i < n; ++i){
        cout << freq[a[i]] << " ";
    }
}
