Answer: Only B
============================================
Explanation:
For situation A,
The pairing (x,y) tells us what a certain student likes in terms of color.
For example, the point (Allen, Red) tells us that Allen likes the color red. We could also have (Allen, Green) telling us he also likes green. Because the input "Allen" maps to more than one output, this means situation A is not a function. A function is only possible if any given input maps to exactly to one output. The input must be in the domain. The domain in this case is the set of all students in the classroom.
In contrast, Situation B is a function because a student will only have one favorite math teacher. I'm interpreting this to mean "number one favorite" and not a situation where a student can select multiple favorites.