1. 

/**
* Angewandte Mathematik, SS11
* Problem: 498 - Polly the Polynomial
* Link: http://uva.onlinejudge.org/external/4/498.html
*
* @author Fabian Trampusch
* @author Robert Schwarz
* @version 1.0, 15/05/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 2.020
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

while (true) {

long[] coefficients = readLongArr(br.readLine());
long[] xValues = readLongArr(br.readLine());

StringBuilder sb = new StringBuilder(coefficients.length);

for (long x : xValues) {
long sum = 0;
for (int cOffset = 0; cOffset < coefficients.length; cOffset++) {
sum += coefficients[cOffset]
* Math.pow(x, coefficients.length - cOffset - 1);
}

sb.append(sum + " ");
}

System.out.println(sb.substring(0, sb.length() - 1));
}
}

public static long[] readLongArr(String line) {
try {
StringTokenizer st = new StringTokenizer(line);

int countElements = st.countTokens();
long[] readInts = new long[countElements];

for (int i = 0; i < countElements; i++) {
readInts[i] = Long.parseLong(st.nextToken());
}

return readInts;
} catch (Exception e) {
System.exit(0);

// I WILL NEVER GET HERE BUT JAVA WANTS ME HERE
return null;
}
}
}