Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

B. Need For Brake

time limit per test

4 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputVasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game!

*n* racers take part in the championship, which consists of a number of races. After each race racers are arranged from place first to *n*-th (no two racers share the same place) and first *m* places are awarded. Racer gains *b* _{ i} points for *i*-th awarded place, which are added to total points, obtained by him for previous races. It is known that current summary score of racer *i* is *a* _{ i} points. In the final standings of championship all the racers will be sorted in descending order of points. Racers with an equal amount of points are sorted by increasing of the name in lexicographical order.

Unfortunately, the championship has come to an end, and there is only one race left. Vasya decided to find out what the highest and lowest place he can take up as a result of the championship.

Input

The first line contains number *n* (1 ≤ *n* ≤ 10^{5}) — number of racers. Each of the next *n* lines contains *s* _{ i} and *a* _{ i} — nick of the racer (nonempty string, which consist of no more than 20 lowercase Latin letters) and the racer's points (0 ≤ *a* _{ i} ≤ 10^{6}). Racers are given in the arbitrary order.

The next line contains the number *m* (0 ≤ *m* ≤ *n*). Then *m* nonnegative integer numbers *b* _{ i} follow. *i*-th number is equal to amount of points for the *i*-th awarded place (0 ≤ *b* _{ i} ≤ 10^{6}).

The last line contains Vasya's racer nick.

Output

Output two numbers — the highest and the lowest place Vasya can take up as a result of the championship.

Examples

Input

3

teama 10

teamb 20

teamc 40

2

10 20

teama

Output

2 3

Input

2

teama 10

teamb 10

2

10 10

teamb

Output

2 2

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/09/2020 09:28:26 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|