#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


struct Graph {
    Graph(const int n)
    {
        edge.resize(n);
    }
    void addEdge(const int from, const int to, const bool t)
    {
        edge[from].push_back({to, t});
    }
    vector<vector<pair<int, bool>>> edge;
};


int main()
{
    while (true) {
        int N, p1, p2;
        cin >> N >> p1 >> p2;
        if (N == 0 and p1 == 0 and p2 == 0) {
            break;
        }
        int p = p1 + p2;
        Graph g(p);
        for (int i = 0; i < N; i++) {
            int u, v;
            string s;
            cin >> u >> v >> s;
            u--, v--;
            const bool reply = s == "yes";
            g.addEdge(u, v, reply);
            g.addEdge(v, u, reply);
        }
        vector<bool> used(p, false);
        using P = pair<int, int>;
        vector<P> comp;
        vector<int> top;
        for (int i = 0; i < p; i++) {
            if (not used[i]) {
                top.push_back(i);
                queue<pair<int, bool>> q;
                q.push({i, true});
                used[i] = true;
                int t = 0;
                int f = 0;
                while (not q.empty()) {
                    const auto p = q.front();
                    (p.second ? t : f)++;
                    const int s = p.first;
                    const int ho = p.second;
                    q.pop();
                    for (const auto& e : g.edge[s]) {
                        if (not used[e.first]) {
                            used[e.first] = true;
                            q.push({e.first, not(ho ^ e.second)});
                        }
                    }
                }
                comp.push_back({t, f});
            }
        }

        const int size = comp.size();
        vector<vector<int>> dp(size + 1, vector<int>(p + 1, 0));
        dp[0][0] = 1;
        for (int i = 0; i < size; i++) {
            for (int j = 0; j <= p; j++) {
                if (dp[i][j]) {
                    dp[i + 1][j + comp[i].first] += dp[i][j];
                    dp[i + 1][j + comp[i].second] += dp[i][j];
                }
            }
        }
        if (dp[size][p1] == 1) {
            vector<bool> honest(size, false);
            int pos = p1;
            for (int i = size - 1; i >= 0; i--) {
                if (dp[i][pos - comp[i].first] == 1) {
                    honest[i] = true;
                    pos -= comp[i].first;
                } else {
                    pos -= comp[i].second;
                    honest[i] = false;
                }
            }
            vector<bool> used(p, false);
            set<int> ans;
            for (int i = 0; i < size; i++) {
                queue<pair<int, bool>> q;
                q.push({top[i], honest[i]});
                used[top[i]] = true;
                while (not q.empty()) {
                    const auto p = q.front();
                    const int s = p.first;
                    const int ho = p.second;
                    if (ho) {
                        ans.insert(s + 1);
                    }
                    q.pop();
                    for (const auto& e : g.edge[s]) {
                        if (not used[e.first]) {
                            used[e.first] = true;
                            q.push({e.first, not(ho ^ e.second)});
                        }
                    }
                }
            }
            for (const int a : ans) {
                cout << a << endl;
            }
            cout << "end" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3300