/**
给出多项式 p(x) = an*x^n + an-1*x^(n-1)..... + a1*x + a0;
给定n,l,k,m 计算 x 从 l到 l+k-1 的p(x)的后m 位的平方的和
用差分序列 ,先计算出前 n项 构造出差分表。。后边的k-n个 用递推可得,从下往上递推。
**/
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static int cal(String str, int m) {
// System.out.println(str+"------->");
int len = Math.min(str.length(), m);
int ans = , tmp;
for (int i = ; i < len; i++) {
tmp = str.charAt(i) - '';
ans += tmp * tmp;
}
return ans;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System. in);
int n = cin.nextInt();
BigInteger l = cin.nextBigInteger();
int k = cin.nextInt();
int m = cin.nextInt();
BigInteger mod = BigInteger. TEN.pow(m);
BigInteger[] a = new BigInteger[];
for (int i = ; i <= n; i++)
a[i] = cin.nextBigInteger();
BigInteger h[][] = new BigInteger[][];
for (int i = ; i < Math.min (n + , k); i++) {
BigInteger res = a[];
for (int j = ; j <= n; j++) {
res = res.multiply(l);
res = res.add(a[j]);
}
res = res.mod(mod);
l = l.add(BigInteger. ONE);
h[][i] = res;
System. out.println(cal(res.toString(), m));
}
if (k > n + ) {
for (int i = ; i <= n; i++) {
for (int j = ; j <= n - i; j++)
h[i][j] = h[i - ][j + ].subtract(h[i - ][j]);
}
}
BigInteger pre[] = new BigInteger[];
for (int i = ; i <= n; i++) {
pre[i] = h[i][n - i];
}
for (int i = n + ; i < k; i++) {
BigInteger res = h[n][];
for (int j = n - ; j >= ; j--) {
res = pre[j].add(res);
res = res.mod(mod);
pre[j] = res;
}
System. out.println(cal(res.toString(), m));
}
}
}