400. The last hour of the contest

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

It's your lucky day - your team took part in the world finals programming contest. The competition has just finished and all competitors are looking forward to the results. Of course your team is not an exception.

According to the rules of the competition, duration of the contest is 5 hours and team standings are frozen during the last hour of the contest — from 241st to 300th minute. Due to this reason the actual results are unknown to the participants and are only announced at the awards ceremony. It is a long-term tradition though, to get a balloon at the world finals for every problem solved. This information can sometimes be of use during the competition.

While waiting for the awards ceremony, your team decided to evaluate chances to win and determine the place which it can take in the final standings. Here is the information that you have:

To solve this problem you should mind the following contest rules:

Frozen standings are given to you in a text form and look as follows:

You are given the frozen standings, and your task is to calculate the minimum and the maximum place your team can get after the contest is over.

Input file contains one or more set of input data.

First lines of each set contain the standings table at the end of the 240th minute in the format described above. In each line the tokens are split with at least one whitespace character. The next line contains the amount of balloons given to all teams within the last hour of the contest (from 241st to 300th minutes). The last line of the set is the name of your team. All team names consist of Latin letters 'A'-'Z', 'a'-'z', numbers and whitespaces. Each team name contains no more than 100 characters, doesn't start/end with a whitespace, and contains not less then 1 non-whitespace character. All team names are unique within a single set of input data. The number of teams is between 1 and 100. The number of problems is between 1 and 26. The total number of rejected attempts in frozen standings table is not more than 1000, but the total number of rejected attempts in final standings is unlimited. The number of balloons is non-negative.

You may assume that the size of the input file is not more than 100 KB.

For every input data set, please print two integer numbers in the line — the minimum and the maximum place your team can get after the contest is over.

sample input
sample output
Rank Team = Penalty X Y
1 Tarasov SU 3 2 33 + +
2 IMHO 1 1 20 + -1
3 Mozgow SU x 33 1 30. +
3 MiTV 1 30 + -3
5 Opel SU 0 0..
Rank Team = Penalty A
1 aa 0 0 -1
1 ba 0 0 -8
2 4
1 2

Online Contester Team © 2002 - 2010. All rights reserved.