#include<bits/stdc++.h>
using namespace std;

using Graph=vector<vector<int>>;

void dfs(int v,set<int>& s,Graph &g){
    if(s.count(v)) return;
    s.insert(v);
    for(int i=0;i<g[v].size();i++){
        dfs(g[v][i],s,g);
    }
}
void solve(int n,int p1,int p2){
    Graph g(2*(p1+p2));
    for(int i=0;i<n;i++){
        int x,y;
        string a;
        cin>>x>>y>>a;
        x--,y--;
        if(a=="no"){
            g[x].push_back(y+p1+p2);
            g[y].push_back(x+p1+p2);
            g[x+p1+p2].push_back(y);
            g[y+p1+p2].push_back(x);
        }
        else{
            g[x].push_back(y);
            g[y].push_back(x);
            g[x+p1+p2].push_back(y+p1+p2);
            g[y+p1+p2].push_back(x+p1+p2);
        }
    }
    vector<int> used(p1+p2,false);
    vector<vector<int>> c1;
    vector<vector<int>> c2;
    for(int i=0;i<p1+p2;i++){
        if(!used[i]){
            set<int> s;
            dfs(i,s,g);
            vector<int> cc1;
            vector<int> cc2;
            for(auto &e:s){
                if(e<p1+p2){
                    used[e]=true;
                    cc1.push_back(e);
                }else{
                    used[e-p1-p2]=true;
                    cc2.push_back(e-p1-p2);
                }
            }
            c1.push_back(cc1);
            c2.push_back(cc2);
        }
    }
    vector<vector<int>> dp(c1.size()+1,vector<int>(p1+p2+1,0));
    dp[0][0]=1;
    for(int i=0;i<c1.size();i++){
        for(int j=0;j<=p1+p2;j++){
            if(j+c1[i].size()<=p1+p2){
                dp[i+1][j+c1[i].size()]+=dp[i][j];
                dp[i+1][j+c1[i].size()]=min(dp[i+1][j+c1[i].size()],2);
            }
            if(j+c2[i].size()<=p1+p2){
                dp[i+1][j+c2[i].size()]+=dp[i][j];
                dp[i+1][j+c2[i].size()]=min(dp[i+1][j+c2[i].size()],2);
            }
        }
    }
    int pos=c1.size();
    if(dp[pos][p1]>=2){
        cout<<"no"<<endl;
    }
    else{
        int val=p1;
        vector<int> ans;
        while(pos>0){
            if(val-(int)(c1[pos-1].size())>=0 && dp[pos-1][val-c1[pos-1].size()]){
                val-=(int)(c1[pos-1].size());
                for(int i=0;i<c1[pos-1].size();i++) ans.push_back(c1[pos-1][i]+1);
                pos--;
            }
            else{
                val-=(int)(c2[pos-1].size());
                for(int i=0;i<c2[pos-1].size();i++) ans.push_back(c2[pos-1][i]+1);
                pos--;
            }
        }
        sort(ans.begin(),ans.end());
        for(int i=0;i<p1;i++) cout<<ans[i]<<endl;
        cout<<"end"<<endl;
    }

}
int main(){
    int n,p1,p2;
    while(cin>>n>>p1>>p2,!(n==0 && p1==0 && p2==0)){
        solve(n,p1,p2);
    }
    return 0;    
}
