#P1525E. Assimilation IV
Assimilation IV
Description
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Monument per turn.
Monocarp has points on the map he'd like to control using the constructed Monuments. For each point he knows the distance between it and each city. Monuments work in the following way: when built in some city, a Monument controls all points at distance at most to this city. Next turn, the Monument controls all points at distance at most , the turn after — at distance at most , and so on. Monocarp will build Monuments in turns and his empire will conquer all points that are controlled by at least one Monument.
Monocarp can't figure out any strategy, so during each turn he will choose a city for a Monument randomly among all remaining cities (cities without Monuments). Monocarp wants to know how many points (among of them) he will conquer at the end of turn number . Help him to calculate the expected number of conquered points!
The first line contains two integers and (; ) — the number of cities and the number of points.
Next lines contains integers each: the -th integer of the -th line () is the distance between the -th city and the -th point.
It can be shown that the expected number of points Monocarp conquers at the end of the -th turn can be represented as an irreducible fraction . Print this fraction modulo , i. e. value where is such number that .
Input
The first line contains two integers and (; ) — the number of cities and the number of points.
Next lines contains integers each: the -th integer of the -th line () is the distance between the -th city and the -th point.
Output
It can be shown that the expected number of points Monocarp conquers at the end of the -th turn can be represented as an irreducible fraction . Print this fraction modulo , i. e. value where is such number that .
Note
Let's look at all possible orders of cities Monuments will be build in:
- :
- the first city controls all points at distance at most , in other words, points and ;
- the second city controls all points at distance at most , or points , and ;
- the third city controls all points at distance at most , or point .
- : the first city controls points and ; the second city — points and ; the third city — point . In total, points.
- : the first city controls point ; the second city — points , and ; the third city — point . In total, points.
- : the first city controls point ; the second city — points , and ; the third city — point . In total, points.
- : the first city controls point ; the second city — points and ; the third city — points and . In total, points.
- : the first city controls point ; the second city — points , and ; the third city — points and . In total, points.