Bill's Binoculars
View as PDFBill recently got a hold of a fresh new pair of binoculars. Of course, there is just one thing left to do: spy on his neighbours!
Across the street, Bill sees  houses laid out in a row. During his spy session, a total of 
 events occur. On the 
 event, 
 people leave House 
 and enter House 
. Intrigued by this, Bill decides to keep track of all of these events. At the end, he wants to figure out the minimum number of people that must exist on that street.
Constraints
Input Specification
The first line contains two space-separated integers  and 
, the number of houses, and number of events, respectively.
The next  lines of input contain three space-separated integers, 
, 
, and 
, indicating that 
 people went from House 
 to House 
.
Output Specification
On the first line, output the minimum number of people in total that must exist on the street.
On the second line, output  space-separated integers, describing the number of people in each house prior to the events, such that the total number of people is minimized. If there are multiple ways of doing this, output any.
Sample Input
4 3
1 2 3
2 4 5
4 1 1
Sample Output
5
3 2 0 0
Explanation
The number of people in each house between each event would be:
(initial count)
(1st event)
(2nd event)
(3rd event)
Comments
Numbers possibly going up to
 is the key information here.