playing one more roguelike PC game. He controls a solitary saint in the game. The saint has n gear openings. There is a rundown of ci things for the I-th opening, the j-th of them expands the saint strength by ai,j. The things for each opening are pairwise particular and are recorded in the expanding request of their solidarity increment. Thus, ai,1
Correct answer only else downvoted
Ivan is playing one more roguelike PC game. He controls a solitary saint in the game. The saint has n gear openings. There is a rundown of ci things for the I-th opening, the j-th of them expands the saint strength by
For each opening Ivan picks precisely one thing. Let the picked thing for the I-th opening be the bi-th thing in the comparing list. The arrangement of decisions [b1,b2,… ,bn] is known as a form. The strength of a form is the amount of the strength increments of the things in it. A few forms are restricted from the game. There is a rundown of m pairwise particular prohibited forms. It's dependable that there's somewhere around one form that is not restricted. What is the develop with the greatest fortitude that isn't restricted from the game? In case there are various develops with greatest fortitude, print any of them.
Input :The main line contains a solitary integer n (1≤n≤10) — the number of hardware openings. The I-th of the following n lines contains the depiction of the things for the I-th space. Initial, one integer ci (1≤ci≤2⋅105) — the number of things for the I-th opening. Then, at that point, ci integers ai,1,ai,2,… ,ai,ci (1≤ai,1<ai,2<⋯<ai,ci≤108). The amount of ci doesn't surpass 2⋅105. The following line contains a solitary integer m (0≤m≤105) — the number of prohibited forms.
Every one of the following m lines contains a depiction of a restricted form — an arrangement of n integers b1,b2,… ,bn (1≤bi≤ci). The forms are pairwise particular, and there's somewhere around one form that is not restricted.
Output : Print the develop with the greatest fortitude that isn't restricted from the game. In case there are different develops with most extreme fortitude, print any of them.
Step by step
Solved in 4 steps with 1 images