#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {vector<int> par; // uf(x,y)->y
    UnionFind(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) {x = operator[](x); y = operator[](y);if (x != y) par[x] = y;}};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int Q, P1, P2, N;
int X[1010], Y[1010]; string A[1010];
//---------------------------------------------------------------------------------------------------
set<int> E[1010];
int co[1010];
int ng = 0;
vector<int> idx[2];
vector<int> grgr[1010];
void dfs(int cu, int c) {
    vector<vector<int>> res(2);

    co[cu] = c;
    fore(i, grgr[cu]) idx[c].push_back(i);
    //idx[c].push_back(cu);

    fore(to, E[cu]) {
        if (co[to] < 0) dfs(to, 1 - c);
        else if (co[to] == co[cu]) {
            ng = 1;
            return;
        }
    }
}
//---------------------------------------------------------------------------------------------------
int dp[606][1206]; int back[606][1206];
void solve() {
    ng = 0;
    rep(i, 0, 1010) E[i].clear();
    rep(i, 0, 606) rep(j, 0, 1206) dp[i][j] = 0;
    rep(i, 0, 1010) grgr[i].clear();

    // make graph
    UnionFind uf(N);
    rep(i, 0, Q) if (A[i] == "yes") uf(X[i], Y[i]);
    rep(i, 0, Q) if (A[i] == "no") {
        int x = uf[X[i]], y = uf[Y[i]];
        if (x == y) {
            printf("no\n");
            return;
        }
        E[x].insert(y);
        E[y].insert(x);
    }
    rep(i, 0, N) grgr[uf[i]].push_back(i);

    // check whether it is bibgraph + grouping
    vector<vector<int>> gr[2];
    rep(i, 0, N) co[i] = -1;
    rep(i, 0, N) if (uf[i] == i and co[i] < 0) {
        idx[0].clear();
        idx[1].clear();
        dfs(i, 0);
        if (ng) {
            printf("no\n");
            return;
        }
        rep(j, 0, 2) gr[j].push_back(idx[j]);
    }

    // dp
    int n = gr[0].size();

    //rep(i, 0, n) printf(">> %d %d\n", gr[0][i].size(), gr[1][i].size());

    dp[0][0] = 1;
    rep(i, 0, n) rep(sm, 0, N + 1) if (dp[i][sm]) {
        dp[i + 1][sm + gr[0][i].size()]++;
        if (2 < dp[i + 1][sm + gr[0][i].size()]) dp[i + 1][sm + gr[0][i].size()] = 2;
        back[i + 1][sm + gr[0][i].size()] = 0;
        dp[i + 1][sm + gr[1][i].size()]++;
        back[i + 1][sm + gr[1][i].size()] = 1;
        if (2 < dp[i + 1][sm + gr[1][i].size()]) dp[i + 1][sm + gr[1][i].size()] = 2;
    }

    if (dp[n][P1] != 1) {
        printf("no\n");
        return;
    }

    // make ans
    vector<int> ans;
    int idx = n, sm = P1;
    while (0 < idx) {
        idx--;
        fore(i, gr[back[idx + 1][sm]][idx]) ans.push_back(i);
        sm -= gr[back[idx + 1][sm]][idx].size();
    }
    sort(all(ans));
    fore(i, ans) printf("%d\n", i + 1);
    printf("end\n");
}
void _main() {
    while (cin >> Q >> P1 >> P2) {
        if (Q + P1 + P2 == 0) return;
        N = P1 + P2;
        rep(q, 0, Q) {
            cin >> X[q] >> Y[q] >> A[q];
            X[q]--; Y[q]--;
        }
        solve();
    }
}


Measured memory_bytes: 6804