### subroutines

def root(ids, id)
  id0 = id
  while ids[id0] != id0
    id0 = ids[id0]
  end
  ids[id] = id0
end

### main

loop do
  n, p0, p1 = gets.split.map(&:to_i)
  break if (n | p0 | p1) == 0
  #p [n, p0, p1]

  pp = p0 + p1
  ids = (0...pp).to_a
  edges = pp.times.map{[]}
  nbrs = pp.times.map{[]}

  n.times do
    xi, yi, ai = gets.strip.split
    xi = xi.to_i - 1
    yi = yi.to_i - 1
    ai = (ai == "yes")

    idx = root(ids, xi)
    idy = root(ids, yi)
    if idx != idy
      ids[idy] = idx
      edges[xi][yi] = edges[yi][xi] = ai
      nbrs[xi] << yi
      nbrs[yi] << xi
    end
  end
  #p ["ids", ids]
  #p ["edges", edges]
  #p ["nbrs", nbrs]

  gids = []
  grps = []
  gn = 0

  for i in (0...pp)
    id = root(ids, i)
    if gids[id].nil?
      gids[id] = gn
      gn += 1
    end
    gid =gids[id]
    grps[gid] = [] if grps[gid].nil?
    grps[gid] << i
  end
  #p grps

  gnts = gn.times.map{[]}
  gtids = gn.times.map{[]}
  
  for gid in (0...gn)
    for tf in [true, false]
      used = gids.map{false}
      vals = gids.map{false}
      st = grps[gid].first
      used[st] = true
      vals[st] = tf
      nt = 0
      tids = []
      if tf
        nt += 1
        tids << st
      end
      q = [st]

      while ! q.empty?
        u = q.shift
        uv = vals[u]
        for v in nbrs[u]
          if ! used[v]
            used[v] = true
            vv = edges[u][v] ? uv : ! uv
            vals[v] = vv
            if vv
              nt += 1
              tids << v
            end
            q << v
          end
        end
      end
      gnts[gid] << nt
      gtids[gid] << tids
    end
  end
  #p gnts
  #p gtids

  dp = (gn + 1).times.map{(p0 + 1).times.map{0}}
  dp[0][0] = 1
  dpids = (gn + 1).times.map{(p0 + 1).times.map{[]}}
  
  for gid in (0...gn)
    ngid = gid + 1
    for t in (0..1)
      gnt = gnts[gid][t]
      gtid = gtids[gid][t]
      for pn0 in (gnt..p0)
        if dp[gid][pn0 - gnt] > 0
          dp[ngid][pn0] += dp[gid][pn0 - gnt]
          dpids[ngid][pn0] = dpids[gid][pn0 - gnt] + gtid
        end
      end
    end
  end

  if dp[gn][p0] != 1
    puts 'no'
  else
    dpids[gn][p0].sort.each{|i| puts i + 1}
    puts 'end'
  end
end