In the Song Dynasty, Wang Kuei failed to pass the official examination and so became a wanderer in Laiyang in Shangdong Province, lacking the means to return home. Jiao Guei-Ying, a prostitute, took him in out of sympathy. Guei-Ying admired him for his talent, so she pledged to marry him and encouraged him to study hard for the next examination.
After staying in Jiao’s house for three years, Wang Quei accepted Guei-Ying and her mother’s money to make a trip to the capital to participate in the official examination. This time he passed the exam as the Zhang-Yuan scholar. However, he now felt disgusted knowing that Guei-Ying was a prostitute and married the daughter of Premier Han, who happened to be the head examiner. He then sent his old servant Wang Xing to carry 300 silver ingots and a divorce document to Liayang to be delivered to Guei-Ying.
Guei-Ying felt extremely disappointed and heartbroken when she received the letter. She went to the Temple of the Sea God, where she and Wang Kuei had once pledged their love to vent her grief, whereupon she hanged herself. After Wang Xing returned to the capital city and reported to Wang Kuei about Guei-Ying’s suicide, he resigned from his position.
Wang Kuei, feeling guilty, saw Guei-Ying that night while reading in his study. Guei-Ying begged Wang Kuei to take her in as she had nowhere to go, but Wang Kuei, who wanted to keep the past in the past, drew his sword in an attempt to kill Guei-Ying. In the end, he accidentally stabbed himself and died.