Dove is the correct way to say it.
Answer:
it may not be clear but somehow it works
you can add some words in there
Do you have a picture of the lines?
The correct answer is <em>who.
</em>The teacher knew it was Sam who was passing notes.
It would be <em>whom </em>in this case:
The teacher knew it was Sam <em>whom </em>they were passing notes to.