In column A there will be a list of names in column B team and column C location

in cell D1 and D2, i want two names they need to be different and not from same location or team.

Is this something that can be done by formula