// AOJ 1080: Everything Starts With Your Vote
// 2018.2.4 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 200009
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

void insert(char *s, int w, int id)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	return -1;
}

#define INF 100000001
typedef struct { char *nm; int x; } T;
T tbl[100002], fav[100002];
char name[100002][12];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { if (b->x - a->x) return b->x - a->x; return strcmp(a->nm, b->nm); }

int check(int k, int m)
{
	int i, f, x, base, sum;
	T *t;

	base = k-m; if (base < 0) return INF;
	sum = 0, t = tbl+base;
	for (i = 0; i < m; i++) {
		f = (strcmp(fav[i].nm, t->nm) <= 0);
		x = t->x - fav[i].x;
		if (x < 0 || (!x && f)) { t++; continue; }
		sum += x; if (!f) sum++;
	}
	return sum;
}

int main()
{
	int N, M, K, L, i, lo, hi, mi;
	char buf[12], *p;

	while (N = in()) {
		M = in(), K = in(), L = in();
		memset(hash, 0, sizeof(hash));

		for (i = 0; i < N; i++) {
			fgets(name[i], 12, stdin);
			tbl[i].nm = p = name[i];
			while (*p > ' ') p++; *p = 0;
			insert(name[i], p-name[i], i);
			tbl[i].x = atoi(p+1);
		}
		for (i = 0; i < M; i++) {
			fgets(p=buf, 12, stdin);
			while (*p > ' ') p++; *p = 0;
			fav[i] = tbl[lookup(buf, p-buf)];
		}
		qsort(tbl, N, sizeof(T), cmp);
		qsort(fav, M, sizeof(T), cmp);

		lo = 0;
		hi = M; if (hi > K) hi = K; hi++;
		while (hi-lo > 1) {
			mi = (lo + hi) >> 1;
			if (check(K, mi) <= L) lo = mi; else hi = mi;
		}
		printf("%d\n", lo);
	}
	return 0;
}
