Maybe?

=IFERROR(INDEX($A$2:$A$100,SMALL(IF($B$2:$B$100="C",IF(($C$2:$C$100={"X","Y","Z"}),ROW($A$2:$A$100)-ROW($A$2)+1)),ROWS($A$2:$A2))),"")
confirmed with CTRL+SHIFT+ENTER and copied down, after adjusting ranges to suit.