Time Travel

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

In future after the time machine was invented it became easier to learn history. Now you can just go to the corresponding year and watch the events by yourself. Professor uses this device to study the system of Berland roads during the Great Road Transformation.

The transformation took kk consectuve years. During these years the system of roads of Berland used to change. There are nn cities in the country, numbered from 11 to nn. Each year these cities were connected by n1n-1 bidirectional roads, for every pair of cities there was a unique path between them.

Every day Professor chooses two cities ss and ff, travels to every year of the Great Road Transformation, one after another, and makes a trip from ss to ff in this year, visiting all roads on the path, including ss and ff. After that he wrote down the number of cities that were visited in all of his kk trips.

Unfortunately, on the day he had completed his work, having had studied all pairs of cities, he lost all of his records. He only has maps of Berland road system for all kk of the Great Road Transformation years.

Help Professor to restore the numbers that he had written down for all possible pairs of cities ss and ff.

입력

The first line of input contains two integers nn and kk --- the number of cities in Berland and the number of years of the Great Road Transformation (1n,k5001 \leq n, k \leq 500).

Then kk descriptions of Berland roads systems follow, one for each year, in the following format: n1n-1 lines of the description contains two integers aa and bb each --- the cities connected by the roads (1a,bn1 \leq a, b \leq n, aba \neq b). 

It is guaranteed that for each of the kk years for each pair of cities there is a unique path between them.

출력

Output nn lines, nn integers in each of them. The jj-th number in the ii-th line must be the number that Professor wrote down if s=is=i and f=jf=j.

힌트

There are 44 cities in Berland in the first sample test. There are 22 years studied by Professor. The map of the road system for the first year is shown on the left, the map for the second year is shown on the right.

Consider the pair of cities s=1s = 1 and f=2f = 2. Traveling to the first year, Professor visits cities 11, 22, 33, 44 on his trip. Traveling to the second year, Professor visits cities 11, 22, 44. So there are 33 cities 11, 22, 44 that will be visited in all his trips, so he writes down the number 33 for this pair of cities.

Consider the pair of cities s=3s = 3 and f=1f = 1. Traveling to the first year, Professor visits cities 11, 33 on his trip. Traveling to the second year, Professor visits cities 11, 33, 44. So there are 22 cities 11, 33 that will be visited in all his trips, so he writes down the number 22 for this pair of cities.