#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

class Edge
{
public:
	int src, dst, flg;
	Edge(int src, int dst, int flg)
		:src(src),dst(dst),flg(flg)
	{}
};

typedef vector<vector<Edge> > Graph;

void paint(int p, int color, Graph& graph, vector<bool>& painted, vector<int>& result, vector<int>& cnt)
{
	cnt[p]++;
	painted[p] = true;
	if(color) result.push_back(p);

	for(int i=0; i<graph[p].size(); i++) {
		Edge& e = graph[p][i];
		if(painted[e.dst]) continue;

		int nc;
		if(color) nc = e.flg; else nc = (e.flg+1)%2;

		paint(e.dst, nc, graph, painted, result, cnt);
	}
}

int dp[305][605];
int bk[305][605];

int main()
{
	int N,V,A,B;
	while(cin >> N >> A >> B, (N||A||B)) {
		
		V=A+B;
		Graph graph(V);
		for(int i=0; i<N; i++) {
			int s,t,g;
			string f;

			cin >> s >> t >> f;
			s--; t--;
			if(f=="yes") g = 1; else g = 0;
			graph[s].push_back(Edge(s,t,g));
			graph[t].push_back(Edge(t,s,g));
		}

		int C=0;
		vector<int> cnt(V, 0);
		vector<vector<vector<int> > > divineList(V, vector<vector<int> > (2));
		
		for(int i=0; i<V; i++) {
			if(cnt[i] >= 2) continue;

			for(int j=0; j<2; j++) {
				vector<bool> painted(V, false);
				vector<int> result;

				paint(i, j, graph, painted, result, cnt);
				divineList[C][j] = result;
			}

			C++;
		}

		divineList.resize(C);

		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;

		for(int i=1; i<=divineList.size(); i++) {
			/*for(int j=0; j<=A; j++) {
				dp[j][i] = dp[j][i-1];
				bk[j][i] = 0;
			}*/

			for(int j=0; j<=A; j++) {

				for(int k=0; k<2; k++) {
					int p = j + divineList[i-1][k].size();
					if(p > A) continue;
					if(dp[j][i-1]==0) continue;

					dp[p][i] += dp[j][i-1];
					bk[p][i] = k+1;
				}
			}
		}

		if(dp[A][divineList.size()] != 1) {
			cout << "no" << endl;
		}
		else {
			int M = A;
			vector<int> res;
			for(int i=divineList.size(); i>0; i--) {
				if(bk[M][i]==0) continue;

				for(int j=0; j<divineList[i-1][bk[M][i]-1].size(); j++)
					res.push_back(divineList[i-1][bk[M][i]-1][j]);

				M-=divineList[i-1][bk[M][i]-1].size();

			}

			sort(res.begin(), res.end());

			for(int i=0; i<res.size(); i++)
				cout << res[i]+1 << endl;

			cout << "end" << endl;
		}
	}		

}