Race is generally organized by distance but this race will be organized by time. In order to predict the winner we will check every 2 seconds.
Let’s say total race time is 7 seconds we will check for (7-1) seconds.
For 7 sec : we will check who is leading at 2 sec, 4 sec, and 6 sec.
Participant who is leading more number of times is winner from prediction perspective.
Now our task is to predict a winner in this marathon.
- At particular time let say at 4th second, top two (top N, in general) participants are at same distance, then in this case both are leading we’ll increase count for both(all N).
- And after calculating at all time slices, if the number of times someone is leading, is same for two or more participants, then one who come first in input sequence will be the winner.
Ex. If participant 2 and 3 are both leading with same number, participant 2 will be the winner.
1 <= T <= 100
1 <= N <= 100
First line contains a single integer N denoting the number of participants.
Second line contains a single integer T denoting the total time in seconds of this Marathon.
Next N lines (for each participant) are as follows :
We have T+1 integers seperated by space.
First T integers are as follows :
ith integer denotes number of steps taken by the participant at the i-th second.
T+1st integer denotes the distance (in meters) of each step.
Index of Marathon winner, where index starts with 1.
2 2 4 3 5 2 6 2 3
3 5 7 4 3 9 3 2 2
1 2 4 2 7 5 3 2 4