Tournament

5

1 votes
Easy
Problem

N players participate in an event. Each player is identified by their index (1 to N). Out of N players only N2 will qualify for next round. Each player plays exactly one match with all other players. So there are total N(N1)2 matches. In each match, two players participate and each player scores some goals. The player with higher goals wins the match and receives +3 points. Player with lower goals loses and receives 0 points. In case of tie, both players receive +1 points.

After all the matches, players are sorted in the following order, and top N2 , players qualify for next round :-

First- players are sorted in decreasing order of their total points; Second- players are sorted in decreasing order of the difference of goals scored and goals conceived; Third- Players are sorted in decreasing order of the number of goals scored; Fourth- In case of tie, Players are sorted in decreasing order of their index.

Print the index of the top N2 players in the increasing order.

Note : N is always even.

 

INPUT

First line contains the integer N, denoting number of players.

Each of the next N(N1)2 lines contains 4 integers, p1 p2 g1 g2.

p1 and p2 are the index of player 1 and player 2 respectively. g1 and g2 are the goals scored by player 1 and player 2 respectively.

 

OUTPUT

Output N2 lines. Index of the players, who qualified for next round in increasing order. Output each index in new line.

 

CONSTRAINTS

1<=N<=50

1<=p1,p2<=N

0<=g1,g2<=100

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Player’s standings after sorting as described above

Player 4(6 points, 5 diff of goals, 6 goals scored)

Player 1(5 points, 1 diff of goals, 4 goals scored)

Player 2(4 points, -2 diff of goals, 2 goals scored)

Player 3(1 point, -4 diff of goals, 2 goals scored)

So, player 4 and 1 qualify for next round.

Editor Image

?