Evaluate a degree-N polynomial with integer coefficients at K given points, all modulo the prime 786433, with N and K up to 250000.
You are given a polynomial f(x)=a0+a1x+a2x2+⋯+aNxNf(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_N x^Nf(x)=a0+a1x+a2x2+⋯+aNxN of degree NNN with integer coefficients.
Given the integers x1,x2,…,xKx_1, x_2, \ldots, x_Kx1,x2,…,xK, write a program that computes f(xj)f(x_j)f(xj) modulo 786433 for every jjj.
The first line contains the degree NNN of the polynomial. (0≤N≤2500000 \le N \le 2500000≤N≤250000)
The second line contains N+1N+1N+1 integers. The iii-th integer is the coefficient ai−1a_{i-1}ai−1. (0≤ai<7864330 \le a_i < 7864330≤ai<786433)
The third line contains the number of integers KKK. (1≤K≤2500001 \le K \le 2500001≤K≤250000)
The fourth line contains x1,x2,…,xKx_1, x_2, \ldots, x_Kx1,x2,…,xK. (0≤xj<7864330 \le x_j < 7864330≤xj<786433)
Print KKK lines. The iii-th line contains f(xi)f(x_i)f(xi) modulo 786433.