1 #include <cstdio>
2 #include <cstdlib>
3 using namespace std;
4
5 int temp, c[10000];
6
7 int main()
8 {
9 int n;
10 while((temp = getchar()) != EOF)
11 {
12 int count = 0;
13 while(temp != '
')
14 {
15 if(temp == '-' || temp >= '0' && temp <= '9')
16 {
17 ungetc(temp, stdin);
18 scanf("%d", &c[count ++]);
19 }
20 temp = getchar();
21 }
22 int flag = 0, data, sum;
23 temp = getchar();
24 while(temp != '
')
25 {
26 if(temp == '-' || temp >= '0' && temp <='9')
27 {
28 ungetc(temp, stdin);
29 scanf("%d", &data);
30 sum = 0;
31 for(int i = 0; i < count; i++)
32 {
33 sum *= data;
34 sum += c[i];
35 }
36 if(flag) printf(" ");
37 printf("%d", sum);
38 flag = 1;
39 }
40 temp = getchar();
41 }
42 printf("
");
43 }
44 return 0;
45 }