ACM Rank Table

No attempts yetTime limit2sMemory limit128 MB

Problem

An ACM-style programming contest is run by judging software that accepts and evaluates each team's submissions (called runs) and shows the standings in a rank table. The scoring rules are:

  1. Every run is either accepted or rejected.
  2. A team solves a problem if at least one of its runs for that problem is accepted.
  3. For a solved problem, the time consumed is the time from the start of the contest to the team's first accepted run for that problem, plus a 20-minute penalty for every earlier run the team made on the same problem before that accepted run. An unsolved problem consumes no time.
  4. A team's total time is the sum of the time consumed over every problem it solved.
  5. Teams are ranked first by the number of solved problems (more solved is better); ties are broken by the smaller total time.
  6. Although the time is shown in minutes, it is measured to a precision of one second, and the seconds are taken into account when ranking teams.
  7. Teams that remain tied after the rules above are ordered by increasing team number.

Given the list of NN runs, each with its submission time and result, produce the rank table for the CC teams.

Input

The input begins with two integers CC and NN. Then follow NN runs, each given as four integers ci pi ti ric_i\ p_i\ t_i\ r_i:

  • cic_i — the team number,
  • pip_i — the problem number,
  • tit_i — the submission time in seconds from the start of the contest,
  • rir_i11 if the run was accepted, 00 otherwise.

The numbers may be separated by spaces or line breaks.

Output

Print the CC team numbers on a single line, separated by single spaces, ordered from the best rank to the worst.

Constraints

  • 1C,N10001 \le C, N \le 1000
  • 1ciC1 \le c_i \le C
  • 1pi201 \le p_i \le 20
  • 1ti360001 \le t_i \le 36000