#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
void dfs(int now, int nowcol, vi &col, vvi &g) {
  for(auto &nxt: g[now]) {
    if(col[nxt/2] == -1) {
      int nxtcol = nowcol ^ (now % 2 != nxt % 2);
      col[nxt/2] = nxtcol;
      dfs(nxt, nxtcol, col, g);
    }
  }
}
bool solve() {
  int n, p1, p2; cin >> n >> p1 >> p2;
  if(n == 0 && p1 == 0 && p2 == 0) return false;
  int sz = p1 + p2;
  if(n == 0) {
    if(p1 > 0 && p2 > 0) {
      cout << "no" << endl;
    } else if(p1 > 0) {
      for(int i=0;i<(p1);++i) {
        cout << i + 1 << endl;
      }
      cout << "end" << endl;
    } else if(p2 > 0) {
      cout << "end" << endl;
    }
    return true;
  }
  vvi g(2 * sz);
  for(int i=0;i<(n);++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    string s; cin >> s;
    if(s == "yes") {
      g[2*u].push_back(2*v);
      g[2*u+1].push_back(2*v+1);
      g[2*v].push_back(2*u);
      g[2*v+1].push_back(2*u+1);
    } else {
      g[2*u].push_back(2*v+1);
      g[2*u+1].push_back(2*v);
      g[2*v].push_back(2*u+1);
      g[2*v+1].push_back(2*u);
    }
  }
  vector<int> col(sz, -1);
  vector<set<int>> a, b;
  vi cnta, cntb;
  vector<bool> sel(n, false);
  for(int i=0;i<2*sz;i+=2) {
    if(col[i/2] == -1) {
      col[i/2] = 0;
      dfs(i, 0, col, g);
      set<int> na, nb;
      int ncnta = 0, ncntb = 0;
      for(int j=0;j<(sz);++j) {
        if(sel[j] || col[j] == -1) continue;
        sel[j] = true;
        if(col[j] == 0) {
          na.insert(j);
          ncnta++;
        } else if(col[j] == 1) {
          nb.insert(j);
          ncntb++;
        }
      }
      a.emplace_back(na);
      b.emplace_back(nb);
      cnta.emplace_back(ncnta);
      cntb.emplace_back(ncntb);
    }
  }
  sz = (int)(a.size());
  vvi dp(sz+1, vi(p1+1, 0));
  vvi pr(sz+1, vi(p1+1, -1));
  dp[0][0] = 1;
  for(int i=0;i<(sz);++i) {
    for(int j=0;j<(p1+1);++j) {
      if(dp[i][j] >= 1) {
        if(j+cnta[i] <= p1) {
          dp[i+1][j+cnta[i]] += dp[i][j];
          chmin(dp[i+1][j+cnta[i]], 2);
          pr[i+1][j+cnta[i]] = j;
        }
        if(j+cntb[i] <= p1) {
          dp[i+1][j+cntb[i]] += dp[i][j];
          chmin(dp[i+1][j+cntb[i]], 2);
          pr[i+1][j+cntb[i]] = j;
        }
      }
    }
  }
  if(dp[sz][p1] != 1) {
    cout << "no" << endl;
  } else {
    int pos = sz;
    int val = p1;
    set<int> ans;
    while(pos != 0) {
      auto prev = pr[pos][val];
      int cnt = val - prev;
      if(cnta[pos-1] == cnt) {
        for(auto &e: a[pos-1]) {
          ans.insert(e+1);
        }
      } else {
        for(auto &e: b[pos-1]) {
          ans.insert(e+1);
        }
      }
      val = prev;
      pos--;
    }
    for(auto &e: ans) {
      cout << e << endl;
    }
    cout << "end" << endl;
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(solve()) {}
}



Measured memory_bytes: 3220