The correct option is D What
When pronouns like 'what' are used to express any kind of surprise or disbelief, they're called exclamatory pronouns and an exclamation mark (!) is used at the end. The given sentence expresses surprise over "a nightmare", and 'what' is the most suitable option as it refers to the "nightmare", hence option D is correct. 'Which' is a question word, and does not express surprise, hence option A is incorrect. Similarly, 'when' and 'who' are question words, the former refers to time and the latter refers to a person, both of which don't relate to "nightmare", and they don't express surprise, hence options B and C are incorrect.