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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef pair<int,int> P;
typedef vector<int> V;
typedef vector<V> VV;
int M;
int god,devil;
int a[2123];
int b[2123];
int c[2123];
void solve(){
    int N=god+devil;
    VV g(N);
    V used(N,-1);
    vector<VV> q;
    //cout<<N<<endl;
    REP(i,M){
        cin>>a[i]>>b[i];
        string s;
        cin>>s;
        a[i]--;b[i]--;
        //cout<<a[i]<<" "<<b[i]<<endl;
        g[a[i]].pb(i);
        g[b[i]].pb(i);
        c[i]=(s=="yes");
    }
    bool ok=true;
    queue<int> que;
    [&](){
        REP(i,N){
            if(used[i]==-1){
                VV ad(2);
                used[i]=0;
                que.push(i);
                while(que.size()){
                    int v=que.front();que.pop();
                    ad[used[v]].pb(v);
                    for(auto &e:g[v]){
                        int u = a[e]^b[e]^v;
                        if(used[u]==-1){
                            if(c[e]==1){used[u]=used[v];}
                            else{used[u]=1-used[v];}
                            que.push(u);
                        }
                        else if(c[e]==1){
                            if(used[u]!=used[v]){ok=false;return;}
                        }
                        else{
                            if(used[u]==used[v]){ok=false;return;}
                        }
                    }
                }
                //for(auto &it:ad[0])cout<<it<<",";cout<<" : ";
                //for(auto &it:ad[1])cout<<it<<",";cout<<endl;                          
                q.pb(ad);
            }
        }
    }();
    if(ok==false){
        cout<<"no"<<endl;
        return;
    }
    int S=q.size();
    VV dp(S+1,V(N+1,-2));
    dp[0][0]=-1;
    REP(i,S){
        REP(j,N){
            if(dp[i][j]!=-2){
                int nxt;
                nxt = j+(int)q[i][0].size();
                if(dp[i+1][nxt]!=-2||dp[i][j]==-3)dp[i+1][nxt]=-3;
                else dp[i+1][nxt]=0;
                nxt = j+(int)q[i][1].size();
                if(dp[i+1][nxt]!=-2||dp[i][j]==-3)dp[i+1][nxt]=-3;
                else dp[i+1][nxt]=1;
            }
        }
    }
    if(dp.back()[god]>=-1){
        vector<int> ret;    
        int num = god;
        for(int i=S-1;i>=0;i--){
            V &qq=q[i][dp[i+1][num]];
            for(auto &it:qq)ret.pb(it+1);
            num-=qq.size();
        }
        sort(ALL(ret));
        for(auto &it:ret)cout<<it<<endl;
        
        cout<<"end"<<endl;
    }
    else{
        cout<<"no"<<endl;
    }
}
int main(){
    while(cin>>M>>god>>devil,M+god+devil){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3300