oh, ok, let's try this (pretty nasty but I think it does what you want)
This first one will check the values in column C
=IF(OR(ISNUMBER(MATCH(IF(ISNUMBER(MATCH(C1,D😀,0)),C1,""),A:A,0)),ISNUMBER(MATCH(IF(ISNUMBER(MATCH(C1,D😀,0)),C1,""),B:B,0))),C1,"")
This one will check the values in column D
=IF(OR(ISNUMBER(MATCH(IF(ISNUMBER(MATCH(D1,C:C,0)),D1,""),A:A,0)),ISNUMBER(MATCH(IF(ISNUMBER(MATCH(D1,C:C,0)),D1,""),B:B,0))),D1,"")
If this isn't what you want, can you post an example spreadsheet with some examples of A-D and what you want as an output based on that?