#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vector<int> g[600];
bool visited[600];
set<int> st[600];

void dfs(int now, bool f, set<int> &s1, set<int> &s2) {
  if (f == 0) s1.insert(ALL(st[now]));
  else s2.insert(ALL(st[now]));
  visited[now] = 1;
  FOR(it, g[now]) {
    if (!visited[*it]) {
      dfs(*it, !f, s1, s2);
    }
  }
}

int dp[301][301];
int pre[301][301];

int main() {
  int n, p1, p2;
  while(cin>>n>>p1>>p2,n||p1||p2) {
    int m = p1+p2;
    UnionFind uf(m);
    vector<pii> nos;
    REP(i,n) {
      int x, y;
      string s;
      cin >> x >> y >> s;
      x--;y--;
      if (s == "yes") {
        uf.unionSet(x,y);
      } else {
        nos.push_back(pii(x,y));
      }
    }
    REP(i,m) st[i].clear();
    REP(i,m) { 
      st[uf.root(i)].insert(i);
    }
    REP(i,m) g[i].clear();
    FOR(it, nos) {
      int a = uf.root(it->first);
      int b = uf.root(it->second);
      g[a].push_back(b);
      g[b].push_back(a);
    }
    memset(visited,0,sizeof(visited));
    vector<pair<set<int>,set<int> > > vp;             // 異なるペア
    REP(i,m) {
      int r = uf.root(i);
      if (!visited[r]) {
        set<int> s1,s2;
        dfs(r,0,s1,s2);
        if (s1.size() < s2.size()) swap(s1,s2);
        vp.push_back(make_pair(s1, s2));
      }
    }
    // FOR(it, vp) {
    //   cout << "(";
    //   FOR(jt, it->first) cout << *jt<< ",";
    //   cout << ")";
    //   cout << "(";
    //   FOR(jt, it->second) cout << *jt<< ",";
    //   cout << ")";
    //   cout << endl;
    // }
    // cout << endl;
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    memset(pre,-1,sizeof(pre));
    REP(i,vp.size()) {
      // REP(j,p1+1) {
      //   dp[i+1][j] = dp[i][j];
      //   pre[i+1][j] = j;
      // }
      int a = vp[i].first.size();
      int b = vp[i].second.size();
      int arr[2] = {a,b};

      for (int j=p1; j>=0; --j) {
        if (dp[i][j] == 0) continue;
        REP(k,2) {
          if (j+arr[k]<=p1) {
            dp[i+1][j+arr[k]] = min(2, dp[i+1][j+arr[k]] + dp[i][j]); // 2以上は全部同じ
            pre[i+1][j+arr[k]] = j;
          }
        }
      }
    }
    if (dp[vp.size()][p1] == 1) {
      set<int> ans;
      int now = p1;
      for (int i=vp.size(); i>0; --i) {
        int num = now - pre[i][now];

        if (vp[i-1].first.size() == num) {
          ans.insert(ALL(vp[i-1].first));
        } else {
          ans.insert(ALL(vp[i-1].second));
        }
        now = pre[i][now];
      }
      assert(ans.size() == p1);
      FOR(it, ans) cout << *it+1 << endl;
      puts("end");
    } else {
      puts("no");
    }
  }
}

Measured memory_bytes: 2092