#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

int dp[605][1205];
int M, p[2];
int N;
map<i_i, vector<vector<int>>> mp;
vector<int> ans;

void solve() {
    mp.clear();
    ans.clear();
    N = p[0] + p[1];
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            dp[i][j] = 0;
        }
    }
    UnionFind uni(2 * N);
    for(int i = 0; i < M; i++) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        a--;
        b--;
        if(s == "yes") {
            uni.merge(a, b);
            uni.merge(a + N, b + N);
        } else {
            uni.merge(a, b + N);
            uni.merge(a + N, b);
        }
    }
    for(int i = 0; i < N; i++) {
        i_i tmp = {uni.root(i), uni.root(i + N)};
        int idx = 0;
        if(tmp.first > tmp.second) {
            swap(tmp.first, tmp.second);
            idx = 1;
        }
        mp[tmp].resize(2);
        mp[tmp][idx].push_back(i);
    }
    /*
    for(auto tmp : mp) {
        cerr << tmp.second[0].size() << " " << tmp.second[1].size() << endl;
    }
    cerr << endl;
    */
    vector<vector<vector<int>>> V;
    for(auto tmp : mp) {
        V.push_back(tmp.second);
    }
    dp[0][0] = 1;
    for(int i = 0; i < V.size(); i++) {
        for(int before = 0; before <= N; before++) {
            for(int j = 0; j < 2; j++) {
                dp[i+1][before+V[i][j].size()] += dp[i][before];
                chmin(dp[i+1][before+V[i][j].size()], 2);
            }
        }
    }
    if(dp[V.size()][p[0]] >= 2) {
        cout << "no" << endl;
        return;
    }
    for(int i = V.size() - 1; i >= 0; i--) {
        if(p[0] - V[i][0].size() >= 0 and dp[i][p[0]-V[i][0].size()] == 1) {
            p[0] -= V[i][0].size();
            for(auto val : V[i][0]) {
                ans.push_back(val);
            }
            continue;
        }
        if(p[0] - V[i][1].size() >= 0 and dp[i][p[0]-V[i][1].size()] == 1) {
            p[0] -= V[i][1].size();
            for(auto val : V[i][1]) {
                ans.push_back(val);
            }
            continue;
        }
    }
    sort(ans.begin(), ans.end());
    for(auto val : ans) {
        cout << val + 1 << endl;
    }
    cout << "end" << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> M >> p[0] >> p[1]) {
        if(M == 0 and p[0] == 0 and p[1] == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 5388