// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int size_;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), size_(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return size_;}
    // x と y の属する集合を併合
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        size_--;
        if(-uf[x] < -uf[y]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
        return true;
    }
};

int dp[610][610], pre[610][610];
int solve_testcase() {
    int N, p1, p2;
    cin >> N >> p1 >> p2;
    if(N == 0 and p1 == 0 and p2 == 0) return 1;

    int M = p1 + p2;
    UnionFind uf(M * 2);
    for(int i=0; i<N; i++) {
        int x, y; string a; cin >> x >> y >> a;
        x--; y--;
        if(a == "yes") {
            uf.unite(x, y);
            uf.unite(x+M, y+M);
        }
        else {
            uf.unite(x, y+M);
            uf.unite(x+M, y);
        }
    }

    vector<bool> visited(M * 2);
    vector<int> sx, sy, group;
    vector< vector<int> > vx, vy;
    for(int i=0; i<M; i++) {
        int f = uf.find(i);
        if(visited[f]) continue;
        visited[f] = true;
        
        int cx = 0, cy = 0;
        vector<int> x, y;
        for(int j=0; j<M; j++) {
            bool same = false;
            if(uf.find(j) == f) {
                cx++;
                x.emplace_back(j+1);
                same = true;
            }
            if(uf.find(j+M) == f) {
                cy++;
                y.emplace_back(j+1);
                same = true;
            }
            if(same) visited[uf.find(j)] = visited[uf.find(j+M)] = true;
        }

        vx.emplace_back(x);
        vy.emplace_back(y);
        sx.emplace_back(cx);
        sy.emplace_back(cy);
        group.emplace_back(f);
    }
    
    fill(dp[0], dp[M+1], 0);
    fill(pre[0], pre[M+1], -1);
    dp[0][0] = 1;
    int G = sx.size();
    for(int i=0; i<G; i++) {
        int x = sx[i], y = sy[i];
        // fprintf(stderr, "x = %d, y = %d\n", x, y);
        for(int j=0; j<=M; j++) {
            // use x
            if(dp[i][j] > 0 and j+x <= p1) {
                dp[i+1][j+x] += dp[i][j];
                if(dp[i+1][j+x] >= 2) dp[i+1][j+x] = 2;
                pre[i+1][j+x] = j;
            }

            // use y
            if(dp[i][j] > 0 and j+y <= p1) {
                dp[i+1][j+y] += dp[i][j];
                if(dp[i+1][j+y] >= 2) dp[i+1][j+y] = 2;
                pre[i+1][j+y] = j;
            }
        }
    }

    if(dp[G][p1] != 1) {
        cout << "no" << endl;
    }
    else {
        int i = G, j = p1;
        vector<int> ans;
        while(i > 0) {
            int ni = i - 1, nj = pre[i][j];
            // fprintf(stderr, "i = %d, j = %d, nj = %d\n", i, j, nj);
            if(j - nj == sx[ni]) {
                for(auto e : vx[ni]) ans.emplace_back(e);
            }
            else if(j - nj == sy[ni]) {
                for(auto e : vy[ni]) ans.emplace_back(e);
            }
            else return 0;
            i = ni, j = nj;
        }

        sort(ans.begin(), ans.end());
        for(auto e : ans) cout << e << endl;
        cout << "end" << endl;
    }
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 5360