which of the following dialogue is grammatically correct

"I can't go through the Haunted Wood, Marilla, cried Anne desperately." I can't go through the Haunted Wood, Marilla." Cried Anne desperately.

I can't go through the Haunted Wood, Marilla. "Cried Anne desperately."

I can't go through the Haunted Wood, Marilla," cried Anne desperately.

The correct dialogue is: "I can't go through the Haunted Wood, Marilla," cried Anne desperately.