#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
struct Unionfind
{
	int par[2100],rank[2100];
	void init()
	{
		for(int i=0;i<2100;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	int find(int x)
	{
		if(x==par[x])return x;
		else return par[x]=find(par[x]);
	}
	void unite(int a,int b)
	{
		a = find(a);
		b = find(b);
		if(a==b)return;
		if(rank[a]<rank[b])par[a]=b;
		else
		{
			par[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
}uf;
int N,p1,p2,M;
vector<pair<vi,vi> >vp;
vector<int> xs[1220];
vector<P> cnt;
int dp[610][610];
int use[610];
bool used[610];
int rec(int x,int num)
{
	if(dp[x][num]!=-1)return dp[x][num];
	if(x==0)
	{
		if(num==cnt[x].fi||num==cnt[x].sec)return dp[x][num]=1;
		else return dp[x][num]=0;
	}
	int res = 0;
	if(num>=cnt[x].fi)res+=rec(x-1,num-cnt[x].fi);
	if(num>=cnt[x].sec)res+=rec(x-1,num-cnt[x].sec);
	return dp[x][num]=res;
}
void restore(int x,int num)
{
	if(x==0)
	{
		if(cnt[x].fi==num)use[x]=0;
		else use[x]=1;
		return;
	}
	if(num>=cnt[x].fi&&rec(x-1,num-cnt[x].fi)==1)
	{
		use[x]=0;
		restore(x-1,num-cnt[x].fi);
	}
	if(num>=cnt[x].sec&&rec(x-1,num-cnt[x].sec)==1)
	{
		use[x]=1;
		restore(x-1,num-cnt[x].sec);
	}
}
int main()
{
	while(1)
	{
		vp.clear();
		cnt.clear();
		for(int i=0;i<610;i++)
		{
			xs[i*2].clear();
			xs[i*2+1].clear();
			use[i]=-1;
			used[i]=false;
		}
		memset(dp,-1,sizeof(dp));
		uf.init();
		scanf("%d %d %d",&N,&p1,&p2);
		if(N==0&&p1==0&&p2==0)break;
		M = p1+p2;
		for(int i=0;i<N;i++)
		{
			int x,y;
			string s;
			cin >> x >> y >> s;
			x--;y--;
			if(s=="yes")
			{
				uf.unite(x,y);
				uf.unite(x+M,y+M);
			}
			else
			{
				uf.unite(x,y+M);
				uf.unite(x+M,y);
			}
		}
		if(p1==p2)
		{
			printf("no\n");
			continue;
		}
		bool flag = false;
		for(int i=0;i<M;i++)if(uf.same(i,i+M))
		{
			flag = true;
			printf("no\n");
			break;
		}
		if(flag)continue;
		vector<int> vs;
		for(int i=0;i<M*2;i++)vs.pb(uf.find(i));
		sort(all(vs));
		vs.erase(unique(all(vs)),vs.end());
		for(int i=0;i<M*2;i++)
		{
			int k = lower_bound(all(vs),uf.find(i))-vs.begin();
			xs[k].pb(i);
		}
		flag = false;
		for(int i=0;i<M;i++)
		{
 			if(used[i])continue;
			int p = lower_bound(all(vs),uf.find(i))-vs.begin();
			pair<vi,vi> tmp;
			P c = P(0,0);
			for(int j=0;j<xs[p].size();j++)
			{
				if(xs[p][j]<M)
				{
					tmp.fi.pb(xs[p][j]);
					c.fi++;
					used[xs[p][j]]=true;
				}
				else
				{
					tmp.sec.pb(xs[p][j]);
					c.sec++;
					used[xs[p][j]-M]=true;
				}
			}
			if(c.fi==c.sec)
			{
				flag = true;
				printf("no\n");
				break;
			}
			vp.pb(tmp);
			cnt.pb(c);
			//cout << c.fi << ' ' << c.sec << endl;
			//for(int i=0;i<tmp.fi.size();i++)cout << (tmp.fi)[i] << ' ';
			//cout << endl;
		}
		if(flag)continue;
		int way = rec(vp.size()-1,p1);
		//cout << way << endl;
		if(way!=1)
		{
			printf("no\n");
			continue;
		}
		restore(vp.size()-1,p1);
		vector<int> ans;
		for(int i=0;i<vp.size();i++)
		{
			if(use[i]==0)
			{
				for(int j=0;j<vp[i].fi.size();j++)ans.pb((vp[i].fi)[j]+1);
			}
			else
			{
				for(int j=0;j<vp[i].sec.size();j++)ans.pb((vp[i].sec)[j]+1-M);
			}
		}
		sort(all(ans));
		for(int i=0;i<ans.size();i++)printf("%d\n",ans[i]);
		printf("end\n");
	}
	return 0;
}

Measured memory_bytes: 2864