#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int n,T,F,i,m;cin>>n>>T>>F;m=T+F;
	if(n+m==0){return false;}
	vector<vector<pair<int,int>>>go(m);
	vector<pair<int,int>>gru(m,mp(-1,-1));
	vector<int>Tg;
	vector<int>Fg;
	for(i=0;i<n;i++){
		int a,b,x;string s;cin>>a>>b>>s;a--;b--;
		x=(s=="yes"?0:1);
		go[a].pub(mp(b,x));
		go[b].pub(mp(a,x));
	}
	int ban=0,tei=0;
	for(i=0;i<m;i++){
		if(gru[i]!=mp(-1,-1)){continue;}
		gru[i]=mp(ban,0);
		stack<int>que;
		que.push(i);
		int nowt=0,nowf=0;
		while(que.size()){
			int t=que.top();que.pop();
			int my=gru[t].sec;
			if(my){nowf++;}else{nowt++;}
			for(auto it:go[t]){
				if(gru[it.fir].sec==(my^it.sec^1)){cout<<"no"<<endl;return true;}
				if(gru[it.fir].sec==-1){
					gru[it.fir]=mp(ban,(my^it.sec));
					que.push(it.fir);
				}
			}
		}
		Tg.pub(nowt);
		Fg.pub(nowf);
		tei+=min(nowt,nowf);
		ban++;
	}
	//for(i=0;i<m;i++){cerr<<"i="<<i<<"gru="<<gru[i].fir<<","<<gru[i].sec<<endl;}
	vector<bitset<301>>dp(ban+1);
	vector<bitset<301>>ep(ban+1);
	dp[0][0]=1;ep[ban][T-tei]=1;
	for(i=0;i<ban;i++){dp[i+1]=dp[i]|(dp[i]<<(abs(Tg[i]-Fg[i])));}
	for(i=ban-1;i>=0;i--){ep[i]=ep[i+1]|(ep[i+1]>>(abs(Tg[i]-Fg[i])));}
	vector<int>ans(ban,-1);
	for(i=0;i<ban;i++){
		if(Tg[i]<Fg[i]){
			if((dp[i]&ep[i+1]).none()){ans[i]=1;}
			if(((dp[i]<<(Fg[i]-Tg[i]))&ep[i+1]).none()){ans[i]=0;}
		}
		if(Fg[i]<Tg[i]){
			if((dp[i]&ep[i+1]).none()){ans[i]=0;}
			if(((dp[i]<<(Tg[i]-Fg[i]))&ep[i+1]).none()){ans[i]=1;}
		}
		//cerr<<"ans["<<i<<"]="<<ans[i]<<endl;
		if(ans[i]==-1){cout<<"no"<<endl;return true;}
	}
	for(i=0;i<m;i++){
		if(ans[gru[i].fir]==gru[i].sec){cout<<i+1<<endl;}
	}
	cout<<"end"<<endl;
	return true;
}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	//gの合計をできるだけn/2-baseに近づける
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3124