playing one more roguelike PC game. He controls a solitary saint in the game. The saint has n hardware spaces. There is a rundown of ci things for the I-th opening, the j-th of them builds the legend strength by ai,j. The things for each opening are pairwise unmistakable and are recorded in the expanding request of their solidarity increment. In this way, ai,1
correct and detailed answer will be upvoted else downvoted.
Ivan is playing one more roguelike PC game. He controls a solitary saint in the game. The saint has n hardware spaces. There is a rundown of ci things for the I-th opening, the j-th of them builds the legend strength by
For each space Ivan picks precisely one thing. Let the picked thing for the I-th space 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 prohibited from the game. There is a rundown of m pairwise unmistakable restricted forms. It's reliable that there's no less than one form that is not restricted.
What is the develop with the greatest fortitude that isn't prohibited from the game? In case there are various develops with greatest fortitude, print any of them.
Input
The principal line contains a solitary integer n (1≤n≤10) — the number of gear spaces.
The I-th of the following n lines contains the depiction of the things for the I-th opening. 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 prohibited form — a grouping of n integers b1,b2,… ,bn (1≤bi≤ci).
The forms are pairwise unmistakable, and there's no less than one form that is not restricted.
Output
Print the develop with the most extreme fortitude that isn't restricted from the game. In case there are numerous develops with most extreme fortitude, print any of them
Step by step
Solved in 4 steps with 1 images