#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


struct edge {
  int from;
  int to;
  bool same;
  edge(int f, int t, bool s):from(f), to(t), same(s) {

  }
  /*bool operator ==(edge &e) {
    return from == e.from&&to == e.to&&same == e.same;
  }*/
};

vector<int>types;
vector<vector<edge>>edges;
pair<vector<int>, vector<int>>dfs(const int now,const bool div) {
  types[now] = div;
  pair<vector<int>, vector<int>>apair;
  if (div)apair.first.push_back(now);
  else apair.second.push_back(now);
  for (auto e : edges[now]) {
    if (types[e.to] == -1) {
      const bool tdiv = e.same ? div : !div;
      auto p(dfs(e.to, tdiv));
      apair.first.insert(apair.first.end(), p.first.begin(), p.first.end());
      apair.second.insert(apair.second.end(), p.second.begin(), p.second.end());
    }
  }
  return apair;
}
struct d{
  int num;
  vector<bool>his;
  d() :num(0), his() {

  }
};
int main() {
  while (1) {
    edges.clear();
    types.clear();
    int N, P, Q; cin >> N >> P >> Q;
    if (!N&&!P&&!Q)break;
    edges.resize(P+Q);
    types.resize(P + Q);
    fill(types.begin(), types.end(), -1);
    vector<vector<int>>gyou(P + Q, vector<int>(P + Q, -1));
    for (int i = 0; i < N; ++i) {
      int x, y; string a; cin >> x >> y >> a;
      x--; y--;
      if (x == y)continue;
      bool same = a == "yes";
      gyou[x][y] = same;
      gyou[y][x] = same;

    }
    for (int i = 0; i < P + Q; ++i) {
      for (int j = 0; j < P + Q; ++j) {
        if (gyou[i][j] != -1) {
          edges[i].push_back(edge(i, j, gyou[i][j]));
        }
      }
    }
    vector<pair<vector<int>, vector<int>>>ps;
    for (int i = 0; i < P + Q; ++i) {
      if (types[i] == -1) {
        auto p = dfs(i, true);
        ps.push_back(p);
      }
    }
    //dp[???][?\???°]
    vector<vector<d>>dp(ps.size() + 1, vector<d>(P + Q +1));
    dp[0][0].num = 1;
    for (int t = 0; t < ps.size(); ++t) {
      for (int dnum = 0; dnum <= P + Q; ++dnum) {
        if (dp[t][dnum].num) {
          for (int i = 0; i < 2; ++i) {
            const int nextdnum = (!i)?dnum + ps[t].first.size():dnum+ps[t].second.size();
            vector<bool>nexthis(dp[t][dnum].his);
            nexthis.push_back(!i);
            dp[t + 1][nextdnum].num+=dp[t][dnum].num;
            if (dp[t + 1][nextdnum].num == 1) {
              dp[t + 1][nextdnum].his = nexthis;
            }
          }
          
        }
      }
    }
    if (dp[ps.size()][P].num == 1) {
      set<int>divs;
      vector<bool>his(dp[ps.size()][P].his);
      for (int t = 0; t < ps.size(); ++t) {
        vector<int>v;
        if (his[t]) {
          v = ps[t].first;
        }
        else {
          v = ps[t].second;
        }
        for (auto n : v) {
          divs.emplace(n);
        }
      }
      for (auto d : divs) {
        cout << d + 1 << endl;
      }
      cout << "end" << endl;
    }
    else {
      cout << "no" << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 6244