#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
string myname;
struct Node {
  string name;
  int score;
  void Read() { cin >> name >> score; }
};
bool operator<(const Node& u, const Node& v) {
  if (u.score != v.score)
    return u.score > v.score;
  else
    return u.name < v.name;
}
bool IsMe(const Node& u) { return u.name == myname; }
int n, m;
Node mas[MAXN];
Node tmp[MAXN];
int add[MAXN];
int MaxScore(int m) {
  copy(mas, mas + n, tmp);
  sort(tmp, tmp + n);
  int mypos = find_if(tmp, tmp + n, IsMe) - tmp;
  if (m == 0) return mypos + 1;
  tmp[mypos].score += add[0];
  sort(tmp, tmp + n);
  mypos = find_if(tmp, tmp + n, IsMe) - tmp;
  int cnt = 1 + mypos;
  for (int i = n - 1; cnt < m; --i, ++cnt) {
    tmp[i].score += add[cnt];
  }
  sort(tmp, tmp + n);
  mypos = find_if(tmp, tmp + n, IsMe) - tmp;
  return mypos + 1;
}
int MinScore(int m) {
  copy(mas, mas + n, tmp);
  sort(tmp, tmp + n);
  int mypos = find_if(tmp, tmp + n, IsMe) - tmp;
  if (m == 0) return mypos + 1;
  if (m == n) {
    tmp[mypos].score += add[--m];
    sort(tmp, tmp + n);
    mypos = find_if(tmp, tmp + n, IsMe) - tmp;
  }
  if (m == 0) return mypos + 1;
  int res = mypos + 1;
  int cur = 0;
  for (int i = n - 1; i > mypos && cur < m; --i) {
    tmp[i].score += add[cur];
    if (tmp[i] < tmp[mypos]) {
      ++cur;
      ++res;
    } else {
      tmp[i].score -= add[cur];
    }
  }
  return res;
}
int main() {
  cin >> n;
  if (n == 1) {
    cout << "1 1" << endl;
    return 0;
  }
  for_each(mas, mas + n, mem_fun_ref(&Node::Read));
  cin >> m;
  for (int i = 0; i < m; ++i) cin >> add[i];
  sort(add, add + m, greater<int>());
  cin >> myname;
  cout << MaxScore(m) << " " << MinScore(m) << endl;
  return 0;
}
