#include <bits/stdc++.h>
using namespace std;
int dp[605][605], pre[605], r[605], gg[605], tag[605][2], jj[605][605],
    cc[605][2];
int tot;
int find(int x) {
  if (x != pre[x]) {
    int temp = pre[x];
    pre[x] = find(pre[x]);
    r[x] = r[x] ^ r[temp];
  }
  return pre[x];
}
void unite(int x, int y, int d) {
  int xx = find(x), yy = find(y);
  if (xx != yy) {
    pre[yy] = xx;
    r[yy] = r[x] ^ r[y] ^ d;
  }
}
int main() {
  int n, p, q, x, y;
  while (scanf("%d%d%d", &n, &p, &q) == 3 && n + p + q) {
    int m = p + q;
    memset(pre, 0, sizeof(pre));
    memset(dp, 0, sizeof(dp));
    memset(gg, 0, sizeof(gg));
    memset(tag, 0, sizeof(tag));
    memset(r, 0, sizeof(r));
    memset(jj, 0, sizeof(jj));
    memset(cc, 0, sizeof(cc));
    for (int i = 1; i <= m; i++) {
      pre[i] = i;
      r[i] = 0;
    }
    while (n--) {
      int a, b;
      char s[5];
      scanf("%d%d%s", &a, &b, s);
      if (s[0] == 'y')
        unite(a, b, 0);
      else
        unite(a, b, 1);
    }
    tot = 0;
    for (int i = 1; i <= m; i++) {
      if (i == find(i)) gg[i] = ++tot;
    }
    for (int i = 1; i <= m; i++) {
      tag[gg[find(i)]][r[i]]++;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= tot; i++) {
      for (int j = 0; j <= m; j++) {
        if ((j - tag[i][0]) >= 0 && (dp[i - 1][j - tag[i][0]])) {
          jj[i][j] = tag[i][0];
          dp[i][j] += dp[i - 1][j - tag[i][0]];
        }
        if ((j - tag[i][1]) >= 0 && (dp[i - 1][j - tag[i][1]])) {
          jj[i][j] = tag[i][1];
          dp[i][j] += dp[i - 1][j - tag[i][1]];
        }
      }
    }
    if (dp[tot][p] != 1)
      printf("no\n");
    else {
      for (int i = tot, j = p; i >= 1 && j > 0; i--) {
        if (tag[i][0] == jj[i][j]) {
          j -= tag[i][0];
          cc[i][0] = 1;
        } else {
          j -= tag[i][1];
          cc[i][1] = 1;
        }
      }
      for (int i = 1; i <= m; i++) {
        if (cc[gg[find(i)]][r[i]]) printf("%d\n", i);
      }
      printf("end\n");
    }
  }
  return 0;
}
