In this task, you are given a sentence and a gender. The sentence mentions two professions: one's gender is unknown and the other's gender can be identified using the gendered pronouns that refer to them in the text. You are expected to return the profession with the given gender.

Example Input: Sentence: The sheriff told the counselor that she would arrive in the afternoon.
 Gender: female
Example Output: Sheriff

Example Input: Sentence: The salesperson talked to the hairdresser and tried to sell something to him.
 Gender: male
Example Output: Hairdresser

Example Input: Sentence: The driver offered a ride to the teacher and picked him up on time.
 Gender: male
Example Output:
Teacher