#K4001. Top Influencers

    ID: 26547 Type: Default 1000ms 256MiB

Top Influencers

Top Influencers

In this problem, you are given (n) users and (m) posts. Each post is represented as a triple ((u, p, l)), where (u) is the user ID, (p) is the post identifier, and (l) is the number of likes the post received. Your task is to determine the order of users in descending order based on their total received likes. In case two users have the same number of likes, the user with the smaller ID should come first.

Formally, let (L(i)) denote the total likes received by user (i) over all posts. You need to output a permutation (P) of ({1,2,\ldots,n}) such that for any (i < j): [ L(P_i) > L(P_j) \quad \text{or} \quad (L(P_i) = L(P_j) \text{ and } P_i < P_j). ]

If a user has no posts, then their total likes is considered to be 0.

inputFormat

The input is given via standard input (stdin). The first line contains two integers (n) and (m), where (n) is the number of users and (m) is the number of posts. The following (m) lines each contain three integers (u), (p), and (l) describing a post: (u) (1-based user id), (p) (post id which can be ignored in the logic), and (l) (the number of likes for that post).

outputFormat

Output a single line to standard output (stdout) containing (n) integers. These integers represent the user IDs sorted in the desired order, separated by a single space.## sample

5 0
1 2 3 4 5