406208: GYM102309 J Jobless Orz Panda

Memory Limit:256 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Jobless Orz Pandatime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

An Orz Panda student who has been training for $$$2.5$$$ years is trying to find a job. The interviewer has given him a $$$n \times n$$$ matrix $$$\mathbf{A}$$$ and $$$n$$$ positive integers $$$b_1, b_2, \cdots, b_n$$$. Then the Orz Panda is asked for the value of

$$$$$$\left(\int_{-\infty}^\infty dx_1 \int_{-\infty}^\infty dx_2 \cdots \int_{-\infty}^\infty dx_n \ [\forall k: 0 \leq y_k(\mathbf{x}) \leq b_k]\right)^2$$$$$$

Here $$$\mathbf{x} = (x_1, \cdots, x_n)^T$$$, and $$$y_k(\mathbf{x})$$$ is the $$$k$$$-th value of the vector $$$\mathbf{A} \mathbf{x}$$$. Can you help the Orz Panda to calculate this value, in order to to get the job?

To avoid floating-point errors, you should output the answer modulo $$$M = 1000000007$$$. It can be proved that if the answer is finite, it should be a rational. So it's possible to represent it as $$$u/d$$$, where $$$u$$$ and $$$d$$$ are two integers, and $$$gcd(u, d) = 1$$$. If the answer is finite, and $$$d^{-1} \mod M$$$ exists, output $$$u \cdot d^{-1} \mod M$$$. Otherwise output "Orz".

Input

There are multiple test cases. Please process until EOF.

For each test case, the first line contains the integer $$$n$$$. The $$$i$$$-th of the following $$$n$$$ lines contains $$$n$$$ integers $$$A_{i,1}, \cdots A_{i,n}$$$, which are the elements in the matrix $$$A$$$.

The next line contains $$$n$$$ integers $$$b_1, \cdots, b_n$$$.

It's guaranteed that $$$1 \leq n \leq 300$$$, $$$1 \leq b_i \leq 10^9$$$, $$$|A_{i, j}| \leq 10^9$$$.

Output

For each test case, if the answer is infinite, or $$$d^{-1}$$$ does not exist, output "Orz". Otherwise, output the answer modulo $$$1000000007$$$.

ExampleInput
2
1 1
1 -1
4 5
2
1 1
1 1
2 2
Output
100
Orz

加入题单

算法标签: