#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct edge {
	int to, cost;
};

int m, num[2];

void solve() {
	int n = num[0] + num[1];
	vector<vector<edge>> G(n);
	rep(i, m) {
		int a, b; string t;
		cin >> a >> b >> t; a--; b--;
		if (t == "yes") {
			G[a].push_back({ b,0 });
			G[b].push_back({ a,0 });
		}
		else {
			G[a].push_back({ b,1 });
			G[b].push_back({ a,1 });
		}
	}
	vector<int> col(n);
	vector<P> v;
	vector<vector<int>> memo;

	vector<bool> used(n, false);
	rep(i, n) {
		if (used[i])continue;
		vector<P> ids;
		int z = 0;
		queue<int> q;
		q.push(i); used[i] = true;
		while (!q.empty()) {
			int id = q.front(); q.pop();
			ids.push_back({ col[id],id });
			rep(j, G[id].size()) {
				edge &e = G[id][j];
				if (used[e.to])continue;
				col[e.to] = col[id] ^ e.cost;
				q.push(e.to);
				used[e.to] = true;
			}
		}
		sort(ids.begin(), ids.end());
		int c0 = 0;
		rep(j, ids.size()) {
			if (ids[j].first == 0)c0++;
		}
		v.push_back({ c0,(int)ids.size() - c0 });
		vector<int>addid;
		rep(j, ids.size())addid.push_back(ids[j].second);
		memo.push_back(addid);
	}
	vector<int> dp(n + 1, 0);
	vector<int> cop(n + 1, 0);
	vector<vector<int>> par(v.size());
	rep(i, v.size())par[i].resize(n + 1,0);
	dp[0] = 1;
	rep(i, v.size()) {
		fill(cop.begin(), cop.end(), 0);
		rep(j, n + 1) {
			if (dp[j] == 0)continue;
			if (j + v[i].first <= n) {
				cop[j + v[i].first] += dp[j];
				par[i][j + v[i].first] = j;
			}
			if (j + v[i].second <= n) {
				cop[j + v[i].second] += dp[j];
				par[i][j + v[i].second] = j;
			}
		}
		rep(j, n + 1) {
			if (cop[j] >= 2)cop[j] = 2;
			dp[j] = cop[j];
		}
	}
	if (dp[num[0]] != 1) {
		cout << "no" << endl;
	}
	else {
		int cur = num[0];
		vector<int> ans;
		per(i, (int)v.size()) {
			int nex = par[i][cur];
			int dif = cur - nex;
			//cout << dif << " " << memo[i].size() << endl;
			if (dif == v[i].first) {
				rep(j, dif) {
					ans.push_back(memo[i][j] + 1);
				}
			}
			else {
				rep1(j, dif) {
					ans.push_back(memo[i][memo[i].size() - j] + 1);
				}
			}
			cur = nex;
		}
		sort(ans.begin(), ans.end());
		rep(i, ans.size())cout << ans[i] << endl;
		cout << "end" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	//cout << fixed << setprecision(10);
	//init();
	while (cin >> m >> num[0] >> num[1], m | num[0] | num[1]) {
		solve();
	}
	//solve();
	//stop
	return 0;
}



Measured memory_bytes: 3248