#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
//??°????????¨
#define MAX_N 800
typedef pair<int,int>P;
vector<P>G[MAX_N];

bool used[MAX_N];
vector<int> color[2][MAX_N+1];

void init(){
	REP(i,MAX_N){
		G[i].clear();
		used[i]=false;
		color[0][i].clear();
		color[1][i].clear();
	}
}

void biparate(int v,int num,int c){
	if(used[v]==true)return;
	used[v]=true;
	color[c][num].push_back(v);
	REP(i,G[v].size()){
		biparate(G[v][i].first,num,(c+G[v][i].second)%2);
	}
}

#define NONE 0
#define UNI 1
#define MUL 2

int main(){
	int n,p1,p2;
	while(cin>>n>>p1>>p2,n+p1+p2){
		init();
		REP(i,n){
			int x,y;
			string s;
			cin>>x>>y>>s;
			x--;y--;
			int z=0;
			if(s=="no")z=1;//no????????¢
			G[x].push_back(P(y,z));
			G[y].push_back(P(x,z));
		}
		//?????¨??°??????
		{
			int num=0;
			REP(i,p1+p2){
				if(used[i]==false){
					biparate(i,num,0);
					num++;
				}
			}
		}
		//??????????????????
		vector<int>np[MAX_N+2];
		//vector<vector<int>>back(MAX_N);
		REP(i,MAX_N+1){
			np[0].push_back(NONE);
		}
		np[0][0]=UNI;
		REP(i,MAX_N){
			if((color[0][i].size()==0)&&(color[1][i].size()==0)){
				np[i+1]=np[i];
				continue;
			}
			REP(j,MAX_N+1){
				np[i+1].push_back(NONE);
			}
			REP(j,MAX_N){
				//0?????\??????
				if(np[i][j]==UNI){
					if(np[i+1][j+color[0][i].size()]==NONE){
						np[i+1][j+color[0][i].size()]=UNI;
					}else{
						//if(color[0][i].size()!=0)
						np[i+1][j+color[0][i].size()]=MUL;
					}
				}
				if(np[i][j]==MUL){
					np[i+1][j+color[0][i].size()]=MUL;
				}
				//1?????\??????
				if(np[i][j]==UNI){
					if(np[i+1][j+color[1][i].size()]==NONE){
						np[i+1][j+color[1][i].size()]=UNI;
					}else{
						//if(color[1][i].size()!=0)
						np[i+1][j+color[1][i].size()]=MUL;
					}
					
				}
				if(np[i][j]==MUL){
					np[i+1][j+color[1][i].size()]=MUL;
				}
			}
		}
		
		
		if(np[MAX_N][p1]==UNI){
			vector<int>ans;
			int now=p1;
			for(int i=MAX_N;i>=0;i--){
				if((color[0][i].size()==0)&&(color[1][i].size()==0))continue;
				//cout<<now<<endl;
				if(np[i][now-color[0][i].size()]==1){
					REP(j,color[0][i].size()){
						ans.push_back(color[0][i][j]);
					}
					now-=color[0][i].size();
				}else{
					REP(j,color[1][i].size()){
						ans.push_back(color[1][i][j]);
					}
					now-=color[1][i].size();
				}
				
			}
			sort(ans.begin(),ans.end());
			REP(i,ans.size()){
				cout<<ans[i]+1<<endl;
			}
			cout<<"end"<<endl;
		}else if(np[MAX_N][p2]==UNI){
		    vector<int>ans;
			int now=p2;
			for(int i=MAX_N;i>=0;i--){
				if((color[0][i].size()==0)&&(color[1][i].size()==0))continue;
				//cout<<now<<endl;
				if(np[i][now-color[0][i].size()]==1){
					REP(j,color[1][i].size()){
						ans.push_back(color[1][i][j]);
					}
					now-=color[0][i].size();
				}else{
					REP(j,color[0][i].size()){
						ans.push_back(color[0][i][j]);
					}
					now-=color[1][i].size();
				}
				
			}
			sort(ans.begin(),ans.end());
			REP(i,ans.size()){
				cout<<ans[i]+1<<endl;
			}
			
			cout<<"end"<<endl;
		}else{
			cout<<"no"<<endl;
		}
		
	}
}

Measured memory_bytes: 5676