There is the word heuristics. It's a relatively simple approach that usually works, although there is no guarantee that it will work. The world is full of heuristics because it is simple and powerful.

Some examples of heuristics include: In an anime program, the popularity of a character is proportional to the total appearance time in the main part of the anime. Certainly this seems to hold true in many cases. However, it seems that I belong to the minority. Only characters with light shadows and mobs that glimpse in the background look cute.

It doesn't matter what other people think of your favorite character. Unfortunately, there are circumstances that cannot be said. Related products, figures and character song CDs, tend to be released with priority from popular characters. Although it is a commercial choice, fans of unpopular characters have a narrow shoulder.

Therefore, what is important is the popularity vote held by the production company of the anime program. Whatever the actual popularity, getting a lot of votes here opens the door to related products. You have to collect votes by any means.

For strict voting, you will be given one vote for each purchase of a related product. Whether or not this mechanism should be called strict is now being debated, but anyway I got the right to vote for L votes. There are a total of N characters to be voted on, and related products of K characters who have won more votes (in the case of the same vote, in dictionary order of names) will be planned. I have M characters in all, and I want to put as many characters as possible in the top K.

I first predicted how many votes each character would get (it's not difficult, I just assumed that a character's popularity is proportional to the sum of its appearance times). Given that this prediction is correct, who and how much should I cast this L-vote to ensure that more related products of my favorite characters are released?



Input

The input consists of multiple cases. Each case is given in the following format.


N M K L
name0 x0
..
..
..
nameN-1 xN-1
fav0
..
..
..
favM-1


The meanings of N, M, K, and L are as described in the problem statement.
namei is the name of the character and xi is the total number of votes for the i-th character.
favi represents the name of the character you like. These names are always different and are always included in the character's name input.


The end of the input is given by a line consisting of N = 0, M = 0, K = 0, and L = 0.


In addition, each value satisfies the following conditions
1 ≤ N ≤ 100,000
1 ≤ M ≤ N
1 ≤ K ≤ N
1 ≤ L ≤ 100,000,000
0 ≤ xi ≤ 100,000,000
namei contains only the alphabet and is 10 characters or less in length.

The number of test cases does not exceed 150.
It is also guaranteed that the number of cases where 20,000 ≤ N does not exceed 20.


Judge data is large, so it is recommended to use fast input.

Output

Output in one line how many of the M characters can be included in the top K.

Example

Input

4 1 3 4
yskwcnt 16
akzakr 7
tsnukk 12
fnmyi 13
akzakr
4 1 3 5
akzakr 7
tsnukk 12
fnmyi 13
yskwcnt 16
akzakr
4 2 2 1
akzakr 4
tsnukk 6
yskwcnt 6
fnmyi 12
akzakr
fnmyi
5 2 3 28
knmmdk 6
skrkyk 14
tmemm 14
akmhmr 15
mksyk 25
knmmdk
skrkyk
5 2 3 11
tmemm 12
skrkyk 18
knmmdk 21
mksyk 23
akmhmr 42
skrkyk
tmemm
14 5 10 38
iormns 19
hbkgnh 23
yyitktk 31
rtkakzk 36
mmftm 43
ykhhgwr 65
hrkamm 66
ktrotns 67
mktkkc 68
mkhsi 69
azsmur 73
tknsj 73
amftm 81
chyksrg 88
mkhsi
hbkgnh
mktkkc
yyitktk
tknsj
14 5 10 38
mktkkc 24
rtkakzk 25
ykhhgwr 25
hrkamm 27
amftm 37
iormns 38
tknsj 38
yyitktk 39
hbkgnh 53
mmftm 53
chyksrg 63
ktrotns 63
azsmur 65
mkhsi 76
mkhsi
hbkgnh
mktkkc
yyitktk
tknsj
0 0 0 0


Output

0
1
1
2
1
4
5
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

ll n,m,k,l;
vector<pair<int,string> > score;
map<string,int> dns;
map<string,int> ranks; 
vector<string> favs;
vector<int> favsRanks;
vector<int> favsDns;
char buf[1000];

// tlðãÊklÉüêé±ÆªÂ\©
bool check(int t){
    if(t>k)
        return false;
    else{
        ll sum=0;
        int ms;
        string mname;
        // tlÌ¤¿Ak-tÈãÌÊðæÁÄ¢éàÌÍ³µA»ÌÙ©Ì¨ÉÂ¢Äl¦é
        bool f=false;
        int p=0;
        for(int i = 0; i < t; i++){
            // A±µÄÊªßçêéÆ±ëÜÅßé
            // »ÝÌÊuÌÜÜÅàcèÌvf·×Äªüè¤é©Ç¤©
            int rfi=favsRanks[i];
            if(!f&&(k-rfi)>=t-i-1)
                continue;
            // à¤ß«êÈ¢ÌÅAæÃ~ÉÊðã¸³¹é
            if(!f){
                ms=score[k+i-t].first;
                mname=score[k+i-t].second;
                f=true;
            }
            // cÁ½àÌðüêéÉ«èépÉ}ü
            ll diff=-favsDns[i]+ms;
            if(mname<favs[i])
                diff++;
            sum+=diff;
        }
        return (sum<=l);
    }
}

void solve(){
    while(cin>>n>>m>>k>>l&&!(n==0&&k==0&&m==0&&l==0)){
        score.clear();favs.clear();dns.clear();ranks.clear();
        favsRanks.clear();
        favsDns.clear();
        for(int i = 0; i < n; i++){
            int s;
            string name;
            //scanf("%s %d\n",buf,&s);
            cin>>name>>s;
            //string name(buf);
            score.push_back(make_pair(-s,name));
            dns[name]=s;
        }
        sort(score.begin(),score.end());
        // ¾_ð³ÌÉßµANðÂ¯é
        for(int i = 0; i < n; i++){
            score[i].first=score[i].first*(-1);
            ranks[score[i].second]=i+1;
        }
        vector<pair<int,string> > vpis;
        for(int i = 0; i < m; i++){
            string name;
            cin>>name;
            vpis.push_back(make_pair(ranks[name],name));
        }
        sort(vpis.begin(),vpis.end());
        for(int i = 0; i < m; i++){
            favs.push_back(vpis[i].second);
            favsRanks.push_back(ranks[vpis[i].second]);
            favsDns.push_back(dns[vpis[i].second]);
        }
        int ub=m;
        int lb=-1;
        while(ub-lb>1){
            int med=(ub+lb)/2;
            if(!check(med))
                ub=med;
            else
                lb=med;
        }
        if(check(ub))
            printf("%d\n",ub);
        else
            printf("%d\n",ub-1);
    }
}


int main(){

    solve();

    return 0;
}