Halliday & Matthiessen (2014: 102):
If the WH- word is, or is part of, a nominal group functioning as Complement in a prepositional phrase, this nominal group may function as Theme on its own, e.g. what in what shall I mend it with?, which house in which house do they live in? If the WH- element serves in a projected clause, it may serve as the Theme of the projecting clause, as in Who do you think pays the rent?, which is the interrogative version of you think somebody pays the rent.