Max is the sole serious monarch of Lovingland, a nation made of cities arranged in a road. However, as a youthful country, none of these cities are connected! Hence, Max wants to build roads between each consecutive city.
To do so, he has access to types of road blocks with a length of and a cost of each. To form an entire road, he can combine some number of blocks together. The length of this road is equal to the sum of the lengths of the road blocks that form it, and its cost is defined similarly.
Each city has a radius , and the distance between city and is . The road that connects these two cities must be within of inclusive. Additionally, its total cost cannot exceed and it cannot use more than of the -th road block. Finally Max can cut off a chunk of road of length and sell it to gain , and he can do this at most for the -th road and -th road block. Max cannot spend a negative amount of money. Can you find a configuration of roads that satisfies these constraints?
Note: for this problem, your team may use any publicly available internet resource, as long as you do not communicate with any other person.
Constraints
Except subtask 3.
Except subtask 3.
Subtask 1 [10%]
Subtask 2 [30%]
Subtask 3 [60%]
Input Specification
The first two lines contain the two integers and . The next line contains space separated integers, denoting the length of each block. The next line contains space separated integers, denoting the cost of each block. The next line contains space separated integers, denoting the distance between each pair of cities. The next line contains space separated integers, denoting the maximum budget allowed for each road. The next line contains space separated integers, denoting the radius of each city. The next lines contain space separated integers. The -th integer on the -th line denotes the maximum block count . The next lines contain space separated integers. The -th integer on the -th line denotes the maximum times Max can sell .
Output Specification
Output lines, each containing integers, denoting how the net amount of each block Max should use to build the road between cities and . The net amount is denoted as the amount of times Max purchased a block minus the amount of times Max sold a block . If it is not possible to build the given road, output impossible
for the given road.
Sample Input
2 3
5 2
8 4
10 15 18
17 25 30
1 2 0 1
2 3
1 8
2 2
0 0
0 0
0 0
Sample Output
1 1
1 4
impossible
Comments