SP26187 CLAW - Captain Claw
Description
Captain Claw is at the bank of a river of acid and he needs to cross it. Thr river is x metres wide but Captain Claw can jump at most d metres.
However, the Captain can jump only on stones which keep appearing in the stream.
Input Format
There are multiple test cases. For each test case.
The first line contains n,x and d.
The next n lines denotes subsequent seconds.
For each line, the first integer, c, denotes the number of number of stones appearing in this second.
Then c integers follow.
The ith integer means that a stone would appears at the position of that integer.
Find the minimum time needed by the Captain to cross the river.
1
Output Format
Print a single integer in each line - the time taken to cross the river.
Output -1 if its not possible to cross the river in n seconds.