/* @JUDGE_ID: 1705PZ 498 C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int i,count;
	double temp;
	double table[100];
	char string[1000];
	char *p;

	while(fgets(string,999,stdin))
	{
		for(p=strtok(string," "),count=0;p;p=strtok(0," "))
			table[count++] = atof(p);

		fgets(string,999,stdin);
		for(p = strtok(string," ");p;p = strtok(0," "))
		{
			temp = 0;
			for(i = 0;i < count - 1;i++)
				temp += table[i] * pow(atof(p),(count - i - 1));
			temp += table[count - 1];
			printf("%.0f ",temp);
		}

		printf("\n");
	}

	return 0;
}
@END_OF_SOURCE_CODE
