The city planners have plans to build N plants in the city which has M shops. Each of the plants can be either built or left in the planning stage.
Each shop requires products from some set of plants to operate. If all plants required by shop j are built, the shop will make an instant one-time profit of pro_j units. Once a plant is built, it will produce enough product to support all shops which depend on it.
Building i-th plant needs investment of pay_i units, and it takes t_i days. Two or more plants can be built simultaneously, so that the time for building multiple plants is the maximum of their building times t_i.
The city planners have enough resources to build all plants, but they want to make a net profit. Specifically, they want to select and build a subset of plants such that the total profit of the shops served minus the total cost of the plants built is at least L units, or find out that it is impossible.
First, find the least possible number of days t such that it is possible to make a profit of at least L units in t days. After that, find the highest possible profit p you can make in t days.
The first line of input contains three integers N, M and L: the number of possible plants, the number of shops and the required profit (1≤N,M≤200, 1≤L≤109).
Then follow N lines. Each of them describes a plant and contains two integers pay_i and t_i: the investment and building time of i-th plant (1≤pay_i≤3⋅104, 1≤t_i≤109).
After that, M lines follow. Each of them describes a shop and starts with an integer profit pro_j (1≤pro_j≤1.2⋅105). Then goes an integer k_j which is the number of plants required for shop j to operate (0≤k_j≤N). It is followed by k_j pairwise distinct integers plant_j,1, plant_j,2, …, plant_j,k_j which are the indices of plants required for shop j to operate (1≤plant_j,r≤N).
If the required plan exists, print two integers t and p: t must be the least number of days in which it is possible to make a profit of at least L units, and p must be the maximum profit that can be made in t days.
If a plan which makes a profit of at least L units does not exist, print "impossible".