Under construction

Still being built. Things may change

Football Championship

Time limit2sMemory limit1024 MB

Summary
Given the standings before the final match, find Vasya's team's rank if it wins, draws, or loses that match, with ties broken by name.
Level

Easy2 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

Vasya is a passionate football fan. He just learned that the match involving his favorite team will be the last one of the championship, and the results of all other matches will be known before it ends.

Vasya wants to calculate the final place of his team in the standings depending on the result of that match. The task is not very hard, but Vasya is afraid he will be too nervous to do it himself, so he asked you to write a program that computes it for him.

A winning team gets 33 points, and a losing team gets 00. In case of a draw, both teams get 11 point each.

Input

The first line contains a positive integer nn, the number of teams in the championship (1≤n≤201 \le n \le 20). The second line contains the name of the team Vasya supports, and the third line contains the name of the opponent in the last match. The following nn lines describe the standings after all matches except the last one. Each line contains a team name and its number of points, separated by a space. All names consist of uppercase Latin letters and are at most twenty characters long.

Output

Print three integers separated by spaces: the place of Vasya's team if it wins the last match, if it draws, and if it loses, respectively. If two teams have equal points, the team with the lexicographically smaller name ranks higher.

Examples2

  1. Example 1

    Input
    8
    ZENIT
    SATURN
    SATURN 45
    SPARTAKM 59
    LOKOMOTIV 41
    CSKA 53
    MOSKVA 52
    ZENIT 58
    DINAMO 41
    AMKAR 41
    
    Expected output
    1 2 2
    
  2. Example 2

    Input
    8
    RUBIN
    ZENIT
    MOSKVA 48
    ZENIT 54
    RUBIN 63
    SATURN 45
    CSKA 52
    DINAMO 42
    LOKOMOTIV 54
    SPARTAKM 55
    
    Expected output
    1 1 1