#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	int n, p1, p2;
	while(cin >> n >> p1 >> p2, n|p1|p2){
		vector< vector< pair<int, int> > > vp(p1+p2);
		bool invalid = false;
		for(int i=0;i<n;i++){
			int a, b; string c;
			cin >> a >> b >> c;
			if(a!=b){
				vp[a-1].push_back(make_pair(b-1, c=="no"));
				vp[b-1].push_back(make_pair(a-1, c=="no"));
			} else if(c=="no"){
				invalid = true;
			}
		}
		if(invalid) { puts("no"); continue; }
		vector< vector<int> > ga, gb;
		int visit[600];
		memset(visit, -1, sizeof(visit));
		for(int i=0;i<p1+p2;i++){
			if(visit[i] != -1) continue;
			vector<int> vi[2];
			queue< pair<int, int> > qu; qu.push(make_pair(i,0));
			while(!qu.empty()){
				pair<int, int> pr = qu.front(); qu.pop();
				int pos = pr.first;
				if(visit[pos] != -1) continue;
				visit[pos] = pr.second;
				vi[pr.second].push_back(pos+1);
				for(int j=0;j<vp[pos].size();j++){
					int next = vp[pos][j].first;
					if(visit[next] != -1){
						if(visit[next] != (pr.second + vp[pos][j].second)%2) invalid = true;
						continue;
					}
					qu.push(make_pair(next, (pr.second + vp[pos][j].second)%2));
				}
			}
			ga.push_back(vi[0]);
			gb.push_back(vi[1]);
		}
		if(invalid) { puts("no"); continue; }
		int dp[601][601];
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for(int i=0;i<ga.size();i++){
			for(int j=0;j<=p1+p2;j++){
				if(dp[i][j]==0) continue;
				dp[i+1][j+ga[i].size()] = min(2, dp[i+1][j+ga[i].size()]+dp[i][j]);
				dp[i+1][j+gb[i].size()] = min(2, dp[i+1][j+gb[i].size()]+dp[i][j]);
			}
		}
		if(dp[ga.size()][p1]!=1){ puts("no"); continue; }
		vector<int> res;
		int cur = p1;
		for(int i=ga.size()-1;i>=0;i--){
			if(cur-ga[i].size() >= 0 && dp[i+1][cur] == dp[i][cur-ga[i].size()]){
				for(int j=0;j<ga[i].size();j++) res.push_back(ga[i][j]);
				cur -= ga[i].size();
			} else {
				for(int j=0;j<gb[i].size();j++) res.push_back(gb[i][j]);
				cur -= gb[i].size();
			}
		}
		sort(res.begin(), res.end());
		for(int i=0;i<res.size();i++) cout << res[i] << endl;
		puts("end");
	}
}