**0 人解决**，3 人已尝试。

**0 份提交通过**，共有 5 份提交。

**9.9** EMB 奖励。

**单点时限: **3.0 sec

**内存限制: **256 MB

We are supposed to make a budget proposal for this multi-site competition. The budget proposal is a matrix where the rows represent different kinds of expenses and the columns represent different sites. We had a meeting about this, some time ago where we discussed the sums over different kinds of expenses and sums over different sites. There was also some talk about special constraints: someone mentioned that Computer Center would need at least 2000K Rials for food and someone from Sharif Authorities argued they wouldn’t use more than 30000K Rials for T-shirts. Anyway, we are sure there was more; we will go and try to find some notes from that meeting.

And, by the way, no one really reads budget proposals anyway, so we’ll just have to make sure that it sums up properly and meets all constraints.

The first line of the input contains an integer , giving the number of test cases. The next line is empty, then, test cases follow: The first line of each test case contains two integers, and , giving the number of rows and columns . The second line contains integers, giving the row sums of the matrix. The third line contains integers, giving the column sums of the matrix. The fourth line contains an integer giving the number of constraints. The next lines contain the constraints. There is an empty line after each test case.

Each constraint consists of two integers and , specifying some entry (or entries) in the matrix (the upper left corner is `1 1`

and `0`

is interpreted as **ALL**, i.e. `4 0`

means all entries on the fourth row and `0 0`

means the entire matrix), one element from the set `{<, =, >}`

and one integer , with the obvious interpretation. For instance, the constraint `1 2 > 5`

means that the cell in the 1st row and 2nd column must have an entry strictly greater than , and the constraint `4 0 = 3`

means that all elements in the fourth row should be equal to .

For each case output a matrix of nonnegative integers meeting the above constraints or the string `IMPOSSIBLE`

if no legal solution exists. **Put one empty line between matrices.**

Input

2 2 3 8 10 5 6 7 4 0 2 > 2 2 1 = 3 2 3 > 2 2 3 < 5 2 2 4 5 6 7 1 1 1 > 10

Output

2 3 3 3 3 4 IMPOSSIBLE

**0 人解决**，3 人已尝试。

**0 份提交通过**，共有 5 份提交。

**9.9** EMB 奖励。

题目标签