#K94952. Find Divisible Segment
Find Divisible Segment
Find Divisible Segment
Lara is a young archaeologist who has discovered an ancient board game in a deserted temple. The board game consists of a grid of size \( n \times m \) filled with integers. To initiate the game, she must find a contiguous segment (i.e. consecutive cells in one row) whose sum is divisible by a given integer \( k \). If multiple segments exist, you can output any one of them. If no such segment exists, output \(-1\).
inputFormat
The input is read from standard input (stdin) as follows:
- The first line contains three integers: \( n \), \( m \), and \( k \) — representing the number of rows, the number of columns, and the divisor respectively.
- The next \( n \) lines each contain \( m \) integers, representing the grid.
outputFormat
If a valid segment is found, print three integers: the 1-indexed row number, the starting column index, and the ending column index of the segment. If no such segment exists, print \(-1\).
## sample3 4 5
4 8 6 2
1 12 10 6
4 3 7 5
1 1 4