Casino
시간 제한2초메모리 제한1024 MB
크루피어 점수가 1부터 k일 때 각 경우마다 방문자가 더 높은 점수를 얻을 확률이 가장 큰 주사위 옵션을 고른다.
문제
When Taja runs out of money, she goes to the casino. Recently a new game appeared at the casino, and Taja wants to master it. Help her.
Two parties of the game are croupier and visitor of the casino. Croupier has a single regular -faced dice, which has all integers from to written on its faces. Croupier starts the game with rolling the dice once. Shown number determines amount of points gained by croupier.
To win, visitor has to gain more points, than croupier did. For this there's suggested a choice out of options. Each option is a pair: the dice and number of its allowed rolls. Each face of each dice has some number written on it. This dice is rolled required number of times, all shown numbers are summed up and this sum is exactly the points gained by a visitor.
But some faces, in addition to numbers, have bonus marks. If shown face has bonus mark, then corresponding amount of points is added to the total, and visitor get additional dice roll. All faces of the same dice are pairwise distinct, which means there's no two identical bonus faces and no two identical ordinary faces. Each dice has at least one face without bonus mark. For every dice, the probability of each of its face being shown is the same.
In this problem it is required that for each possible amount of croupier's points from to you determine visitor's rolling option number, which leads to the maximal probability to gain stricly greater points than croupier did.
입력
First line of the input contains single integer () --- number of dice rolling options.
Next lines contain descriptions of options in the following format.
First number () --- number of allowed rolls. Second number () --- number of dice faces. Next numbers --- numbers written on the faces. is either simply a number from to , meaning amount of points, or it can have additional plus sign <<+>> (ASCII ) in front of the number, which is the bonus mark. For every dice, its numbers without plus sign are unique, all numbers with plus sign are unique, and there's at least one face without bonus mark.
Last line contains single integer , which always equals ().
출력
Output should contain lines, each of which contains single integer --- number of the best option, which will allow to win with maximal probability by gaining more than points (this probability shouldn't deviate from the right answer more than ).
Dice are numbered from in the order thay are given in the input.
힌트
Answer for the first sample could conain on the first line, and the last could be any from to .