Evil Pu*&le

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

You have been given N polynomial function, f[1], f[2], ..., f[N].

Each one has the following form: f[i](x) = a[i](x-b[i][0])(x-b[i][1])...(x-b[i][N-3]).

Then you need to answer Q query on these function. Each query you have to return

Here the sum is computed over all permutations σ of the set {0, 2, ..., n-1} and for each permutation σ, sgn(σ) denotes the signature of σ; it is +1 for even σ and −1 for odd σ.

Evenness or oddness can be defined as follows:

the permutation is even (odd) if the new sequence can be obtained by an even number (odd, respectively) of switches of numbers.

t[1], t[2], ... t[N] are given.

N ≤ 1000, Q ≤ 100, all of them are integer.

Input

n

[a0, a1, ..., an-1] (The first line following n is a, than come a n*(n-2) matrix b .. . )

[b0,0, b0,1, ..., b0,n-3]

[b1,0, b1,1, ..., b1,n-3]

.. .

[bn-1,0, bn-1,1, ..., bn-1,n-3]

[t0, t1, ..., tn-1]  (Here following q query .. . )

... 

Output

For each query, simply print the result.

Sample Input

3
1 1 1
10
25
40
1
1 2 3

Sample Output

0

Hint

 。。鸣谢:doc。。。)

Source

xiaodao

Manager

Information
Solved Number2
Submit Number4
Problem Tags
math
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel