#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef pair PII; typedef vector VI; typedef vector VPII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef double DB; #define pb push_back #define mset(a, b) memset(a, b, sizeof a) #define all(x) (x).begin(), (x).end() #define bit(x) (1 << (x)) #define bitl(x) (1LL << (x)) #define sqr(x) ((x) * (x)) #define sz(x) ((int)(x.size())) #define counti(x) (__builtin_popcount(x)) #define clz(x) (__builtin_clz(x)) #define ctz(x) (__builtin_ctz(x)) #define countl(x) (__builtin_popcountll(x)) #define rep(i, n) for (int (i) = 0; (i) < (int)(n); ++(i)) #define Error(x) cout << #x << " = " << endl #define X first #define Y second template inline void chkmax(T& x, U y) { if (x < y) x = y; } template inline void chkmin(T& x, U y) { if (y < x) x = y; } #define MX 123456 #define MOD 1000000007 int val[25][MX]; int f[MX], g[MX]; inline void add(int& x, int y) { if ((x += y) >= MOD) x -= MOD; } int C(int n, int k) { if (k < 0 || k > n) return 0; int ret = 1LL * f[n] * g[k] % MOD; return 1LL * ret * g[n - k] % MOD; } void init() { f[0] = f[1] = 1; for (int i = 2; i < MX; i++) f[i] = 1LL * f[i- 1] * i % MOD; g[0] = g[1] = 1; for (int i = 2; i < MX; i++) { g[i] = 1LL * (MOD - MOD / i) * g[MOD % i] % MOD; } for (int i = 2; i < MX; i++) { g[i] = 1LL * g[i] * g[i - 1] % MOD; } for (int j = 1; j < MX; j++) val[1][j] = 1; for (int i = 1; i < 20; i++) { for (int j = 2; j < MX; j++) if (val[i][j]) { for (int k = 2 * j; k < MX; k += j) { add(val[i + 1][k], val[i][j]); } } } } int F[MX]; int n, K; int ans[MX]; int main() { int Tcase; init(); for (scanf("%d", &Tcase); Tcase--;) { cin >> n>>K; for (int j = 1; j <= n; j++) scanf("%d", F + j); for (int j = 1; j <= n; j++) ans[j] = F[j]; for (int j = 1; j <= n; j++) { for (int k = 2 * j; k <= n; k += j) { for (int l = 1; l <= 20 && l <= K; l++) if (val[l][k / j]) { int x = val[l][k / j]; add(ans[k], 1LL * C(K, l) * x % MOD * F[j] % MOD); } } } for (int i = 1; i <= n; i++) { printf("%d%c", ans[i], i < n ? ' ' : '\n'); } } return 0; }