Tom Sawyer and His Friends
Tom Sawyer's friends take turns painting a fence with various colors. Each friend paints a series of consecutive sections in a specific color, and colors may be reused. New paint layers over any previous ones.
For each paint color, determine how many sections will ultimately be painted in that color after all friends have finished painting.
Input
The first line of the input contains two integers N (1 ≤ N ≤ 10^9) and K (1 ≤ K ≤ 50000)—representing the total number of sections on the fence and the number of different paint colors, respectively.
The second line contains a single integer M (0 ≤ M ≤ 50000)—the number of friends painting the fence.
The following M lines each describe the painting activity of the i-th friend with three integers c_i, l_i, r_i (1 ≤ c_i ≤ K, 1 ≤ l_i ≤ r_i ≤ N)—indicating the paint color number used by the i-th friend, and the first and last sections they painted, respectively.
Output
Output a single line containing K integers: the i-th integer should represent the number of sections painted with the i-th color.