Codeforces Beta Round 66
B
Need For Brake
Codeforces
2000
原题
← AC →
翻译中…

Vasya 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.

翻译中…

样例

Input #1
3
teama 10
teamb 20
teamc 40
2
10 20
teama
Output #1
2 3
InputCopy OutputCopy
Input #2
2
teama 10
teamb 10
2
10 10
teamb
Output #2
2 2
InputCopy OutputCopy
题目信息
题号
73B
时间限制
4 s
内存限制
256 MB
标签
二分
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。