public static void main(String[] args) throws Throwable{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for (; ; ) {
			StringTokenizer st = new StringTokenizer(in.readLine().trim());
			int P = parseInt(st.nextToken()), V = parseInt(st.nextToken()), E = parseInt(st.nextToken());
			if(P==0&&E==0&&V==0)break;
			namePowers = new String[P];
			powers = new int[P][2];
			for (int i = 0; i < powers.length; i++){
				st = new StringTokenizer(in.readLine().trim());
				namePowers[i] = st.nextToken();
				powers[i][0] = parseInt(st.nextToken());
				powers[i][1] = parseInt(st.nextToken());
			}
			villansPowers = new int[V];
			villansDefens = new TreeSet[V];
			for (int i = 0; i < villansDefens.length; i++) {
				st = new StringTokenizer(in.readLine().trim());
				st.nextToken();
				villansPowers[i] = parseInt(st.nextToken());
				st = new StringTokenizer(st.nextToken(), ",");
				villansDefens[i] = new TreeSet<String>();
				for (; st.hasMoreTokens(); )villansDefens[i].add(st.nextToken()); 
			}
			mem = new long[P][V];
			if(function(0, 0)>E)System.out.println("No");
			else System.out.println("Yes");
			
		}
	}