/*
power by Solo_Dance
*/

#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>


#define eps 1e-8
using namespace std;
#define ms(a, b) memset((a), (b), sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int N = 1e3 + 205;
const int M = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const ll ll_max = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;

inline ll read() {
    ll res = 0;
    bool f = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = 1;
        ch = getchar();
    }
    while (ch <= '9' && ch >= '0') {
        res = (res << 3) + (res << 1) + ch - '0';
        ch = getchar();
    }
    return f ? (~res + 1) : res;
}

int f[N];

inline int tofind(int x) {
    return f[x] == x ? x : f[x] = tofind(f[x]);
}
inline void tojoin(int a, int b) {
    f[tofind(a)] = tofind(b);
}
int dp[N][N];
vector<int>ve[N][2];
vector<int>ans;

int m, p, q;
int vis[N];
void solve(){
    int n = p + q;
    for (int i = 1; i <= 2 * n; ++i) f[i] = i;
    char op[10];
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d%d%s", &x, &y, op);
        if (op[0] == 'y') tojoin(x, y), tojoin(x + n, y + n);
        else tojoin(x, y + n), tojoin(x + n, y);
    }
//  可以不用
//    for (int i = 1; i <= n; ++i){
//        if (tofind(i) == tofind(i + n)){
//            puts("no");
//            return;
//        }
//    }
    int tot = 0;
    ms(vis, 0);
    for (int i = 1; i <= n; ++i){
        if (vis[i]) continue;
        ++tot;
        ve[tot][0].clear();
        ve[tot][1].clear();
        int f0 = tofind(i), f1 = tofind(i + n);
        for (int j = 1; j <= n; ++j){
            if (vis[j]) continue;
            if (tofind(j) == f0) ve[tot][0].push_back(j), vis[j] = 1;
            if (tofind(j) == f1) ve[tot][1].push_back(j), vis[j] = 1;
        }
    }
    ms(dp, 0);
    dp[0][0] = 1;
    for (int i = 1; i <= tot; ++i){
        int s0 = ve[i][0].size();
        int s1 = ve[i][1].size();
        for (int j = p; j >= 0; --j){ // 记住 这里不是1 是0！！！！！！！
            if (j >= s0) dp[i][j] += dp[i - 1][j - s0];
            if (j >= s1) dp[i][j] += dp[i - 1][j - s1];
        }
    }
    if (dp[tot][p] != 1) puts("no");
    else {
        ans.clear();
        int pre = p;
        for (int i = tot; i >= 1; --i){
            int s0 = ve[i][0].size();
            if (pre >= s0 && dp[i - 1][pre - s0] == 1){
                pre -= s0;
                for (int j = 0; j < s0; ++j) ans.push_back(ve[i][0][j]);
                continue;
            }
            int s1 = ve[i][1].size();
            if (pre >= s1 && dp[i - 1][pre - s1] == 1){
                pre -= s1;
                for (int j = 0; j < s1; ++j) ans.push_back(ve[i][1][j]);
            }
        }
        sort(ans.begin(), ans.end());
        int sz = ans.size();
        for (int i = 0; i < sz; ++i)
            printf("%d\n", ans[i]);
        puts("end");
    }
}

int main() {
    while(cin >> m >> p >> q && (m || p || q)) solve();
    return 0;
}

/*
2 1 27
22 25 yes
5 27 yes
0 0 0
no
 * */


Measured memory_bytes: 8860