/* @JUDGE_ID: 1705PZ 498 C */
#include <ctype.h>
#include <stdio.h>
#include <math.h>

int main()
{
	int i,flag,count,head,neg,end = 0;
	char ch;
	double temp,sum;
	double table[1024];


	while(!end){
		flag = 0; count = 0; temp = 0; neg = 0;
		while(!end)
		{
			ch = fgetc(stdin);
			if(isdigit(ch) || ch == '-'){
				if(ch == '-'){
					neg = 1;
				}else if(flag){
					temp = temp * 10 + ch - '0';
				}else{
					temp = ch - '0';
					flag = 1;
				}
			}else{
				if(flag){
					if(neg)
						temp *= -1;
					table[count++] = temp;
					flag = 0;
				}else{
					if(neg)
						neg = 0;
				}
				if(ch == '\n')
					break;
			}
			if(ch == EOF)
				end = 1;
		}
		flag = 0; temp = 0; sum = 0; head = 1; neg = 0;
		while(!end)
		{
			ch = fgetc(stdin);
			if(isdigit(ch) || ch == '-'){
				if(ch == '-'){
					neg = 1;
				}else if(flag){
					temp = temp * 10 + ch - '0';
				}else{
					temp = ch - '0';
					flag = 1;
				}
			}else{
				if(flag){
					if(neg){
						temp *= -1;
						neg = 0;
					}
					for(i = 0;i < count - 1;i++)
						sum += table[i] * pow(temp,count - i - 1);
					sum += table[count - 1];
					if(!head)
						printf(" ");
					printf("%.0f",sum);
					head = 0;
					flag = 0;
					sum = 0;
				}else{
					if(neg)
						neg = 0;
				}
				if(ch == '\n'){
					printf("\n");
					break;
				}else if(ch == EOF){
					end = 1;
				}
			}
		}
	}

	return 0;
}
@END_OF_SOURCE_CODE

