#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 2e3 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int N,P1,P2;
int p[MAXN],siz[MAXN],siz_others[MAXN],pp[MAXN];
int mark[MAXN],OK[MAXN];
int dp[666][666];
pair<pair<int,int> ,pair<int,int> > pre[666][666];

bool DFS(int i,int j){
//    printf("i = %d , j = %d\n",i,j);
    if(i==0&&j==0) return true;
    if(dp[i][j]>1) return false;
    int id=pre[i][j].first.first;
    int ok=pre[i][j].first.second;
    int prei=pre[i][j].second.first;
    int prej=pre[i][j].second.second;
    OK[id]=ok;
//    printf("OK[%d] -> %d\n",id,ok);
    return DFS(prei,prej);
}

int Find(int x){
    return p[x]==x ? x : p[x]=Find(p[x]);
}

int Findpp(int x){
    return pp[x]==x ? x : pp[x]=Findpp(pp[x]);
}

int same(int u,int v){
    return Find(u)==Find(v);
}

void unite(int u,int v){
    int x=Find(u);
    int y=Find(v);
    if(x!=y){
        siz[x]+=siz[y];
        p[y]=x;
    }
}

void work(){
    while(~scanf("%d%d%d",&N,&P1,&P2)){
        if(N==0&&P1==0&&P2==0) break;
        int P=P1+P2;
        for(int i=1;i<=P*2;i++) p[i]=i,siz[i]=siz_others[i]=0,pp[i]=i;
        for(int i=0;i<N;i++){
            int x,y;
            char s[10];
            scanf("%d%d%s",&x,&y,s);
            if(s[0]=='y'){
                unite(x,y);
                unite(x+P,y+P);
            }
            else{
                unite(x+P,y);
                unite(x,y+P);
            }
            int ppx=Findpp(x);
            int ppy=Findpp(y);
            pp[ppx]=ppy;
        }
        if(P1==P2) printf("no\n");
        else{
            for(int i=1;i<=P;i++){
                int ppx=Findpp(i);
                int x=Find(ppx);
                int y=Find(i);
                if(x==y) siz[ppx]++;
                else siz_others[ppx]++;
            }
            vector<pair<int, pair<int,int> > > v;
            queue<pair<int, pair<int,int> > > q;
            v.clear();
            while(!q.empty()) q.pop();
            q.push(make_pair(-1,make_pair(0,0)));
            memset(dp,0,sizeof(dp));
            for(int i=1;i<=P;i++)if(pp[i]==i) v.push_back(make_pair(i,make_pair(siz[i],siz_others[i])));
//            printf("v:\n");
//            for(int i=0;i<v.size();i++){
//                printf("%d: %d %d\n",v[i].first,v[i].second.first,v[i].second.second);
//            }
            for(int i=0;i<v.size();i++){
                int id=v[i].first;
                int X=v[i].second.first;
                int Y=v[i].second.second;
                while(1){
                    pair<int, pair<int,int> > pr=q.front();
                    if(pr.first==i) break;
                    q.pop();
                    int preX=pr.second.first;
                    int preY=pr.second.second;
                    dp[preX+X][preY+Y]++;
                    pre[preX+X][preY+Y]=make_pair(make_pair(id,1),make_pair(preX,preY));
                    if(dp[preX+X][preY+Y]==1) q.push(make_pair(i,make_pair(preX+X,preY+Y)));
                    dp[preX+Y][preY+X]++;
                    pre[preX+Y][preY+X]=make_pair(make_pair(id,-1),make_pair(preX,preY));
                    if(dp[preX+Y][preY+X]==1) q.push(make_pair(i,make_pair(preX+Y,preY+X)));
                }
            }
            memset(OK,0,sizeof(OK));
            if(!DFS(P1,P2)){
                printf("no\n");
                continue;
            }
//            printf("OK:\n");
//            for(int i=0;i<v.size();i++){
//                printf("OK[%d] = %d\n",v[i].first,OK[v[i].first]);
//            }
            vector<int> ans;
            for(int i=1;i<=P;i++){
                int fa=Findpp(i);
                int x=Find(i);
                int y=Find(fa);
                if((x==y&&OK[fa]==1)||(x!=y&&OK[fa]==-1)) ans.push_back(i);
            }
            sort(ans.begin(),ans.end());
            for(int i=0;i<ans.size();i++) printf("%d\n",ans[i]);
            printf("end\n");
        }
    }
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 11868