TIME FOR COFFEE
In the city, there are N public transport stops and M bus routes. Each bus follows a circular route that begins and ends at the central stop, numbered 1. The buses start operating at 6:00 AM; prior to this, all drivers gather for coffee before embarking on their routes. The travel time between any two stops is 5 minutes, which includes the time for passengers to board and alight. Whenever all M bus drivers converge at the central stop numbered 1, they take a coffee break.
Your task is to determine the next time they will all meet for coffee.
Input Data
The first line contains two integers, M and N. Each of the following M lines describes the sequence of stops for the i-th route (i=1..M), starting and ending with stop number 1. It is guaranteed that the meeting will occur within the same day. All numbers are natural numbers.
Output Data
Output the next coffee time, which is the moment when all M buses will once again meet at stop number 1.