A city contains N stations. Also in the city circulate M buses. The i-th bus has an itinerary consisting of ti stations: si,1,si,2,...,si,ti. At moment 0 it is at the station si,1, and then each minute he travels to the next station. When it reaches the end it goes back to the begging and starts again. At moment 0 you are at station 1. If at any moment you and a bus are at the same station, you can get on it and travel with it. You can get off at any station. The same station can appear multiple times in the itinerary of the bus, but not adjacent to each other (in particular, the last station is adjacent to the first). You can only travel by bus. You are interested in finding the minimum amount of time you need to get to each station, or state that it is impossible.
You can only travel in one bus at a time, but you can use multiple buses to reach your destination. There can be multiple buses at the the same station at the same time. Getting in and off a bus is instantaneous.
Input
The first line contains 2 integers N and M - the number of stations and the number of buses respectively.
Each of the next M lines contain an integer ti followed by ti integers si,1,si,2,...,si,ti - the itinerary of a bus.
Output
Print N−1 numbers - the i-th number is the minimum amount of time needed to reach the (i+1)-th station, or 1 if it is impossible.
Constraints
2≤N≤105
1≤M≤105
2≤ti
1≤si,j≤N
si,j≠si,j−1
si,n≠si,1
The sum of all ti is not greater then 2∗105
If he waits at station one for one minute, and then takes the second bus, he can reach station 2 in two minutes and station 6 in 3 minutes.
If he waits two minutes at the first station and then takes the 3rd bus, he can reach station 3 in 3 minutes, station 4 in 4 minutes.
If he then waits another minute at station 4 and then takes the first bus, then he can reach station 5 in 6 minutes.
He can't reach stations 7 and 8.