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

class UnionFind {
private:
  vector<int> par, rank;
public:
  UnionFind(int n) {
    par = rank = vector<int>(n);
    for(int i = 0; i < n; ++i) par[i] = i;
  }

  int find(int x) {
    return par[x] == x ? x : par[x] = find(par[x]);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
  }
};

int main() {
  for(int n, p1, p2; cin >> n >> p1 >> p2 && (n|p1|p2); ) {
    int m = p1+p2;
    UnionFind uf(m*2);
    for(int i = 0; i < n; ++i) {
      int x, y;
      string a;
      cin >> x >> y >> a;
      --x; --y;
      if(a == "yes") {
        uf.unite(x, y);
        uf.unite(x+m, y+m);
      } else {
        uf.unite(x, y+m);
        uf.unite(x+m, y);
      }
    }

    bool no_flag = false;
    map<int, pair<int, int> > group;
    for(int i = 0; i < m; ++i) {
      if(uf.same(i, i+m)) {
        no_flag = true;
        break;
      }
      int root = uf.find(i);
      int add = 1;
      if(root >= m) {
        root -= m;
        add = 0;
      }
      group[root].first++;
      group[root].second += add;
    }
    if(no_flag) {
      cout << "no" << endl;
      continue;
    }

    vector<int> roots;
    vector<pair<int, int> > v;
    for(map<int, pair<int,int> >::iterator it = group.begin();
        it != group.end(); ++it) {
      roots.push_back(it->first);
      v.push_back(make_pair(it->second.second, 
                            it->second.first - it->second.second));
    }

    int size = v.size();
    vector<vector<int> > dp(size+1, vector<int>(p1+1, 0));
    vector<vector<int> > prev(size+1, vector<int>(p1+1, -1));
    dp[0][0] = 1;
    for(int i = 0; i < v.size(); ++i) {
      for(int j = 0; j <= p1; ++j) {
        if(!dp[i][j]) continue;
        try {
          int nj = j + v[i].first;
          if(nj > p1) throw 0;
          dp[i+1][nj] += 1;
          prev[i+1][nj] = 0;
        } catch(...) {}
        try {
          int nj = j + v[i].second;
          if(nj > p1) throw 0;
          dp[i+1][nj] += 1;
          prev[i+1][nj] = 1;
        } catch(...) {}
      }
    }

    if(dp[v.size()][p1] != 1) {
      cout << "no" << endl;
      continue;
    }

    vector<int> r(m*2);
    {
      int i = v.size();
      int j = p1;
      while(prev[i][j] != -1) {
        if(prev[i][j] == 0) {
          r[roots[i-1]] = 1;
          j -= v[i-1].first;
        } else {
          r[roots[i-1]+m] = 1;
          j -= v[i-1].second;
        }
        --i;
      }
    }
    for(int i = 0; i < m; ++i) {
      if(r[uf.find(i)]) {
        cout << i+1 << endl;
      }
    }
    cout << "end" << endl;
  }
  return 0;
}