It can be seen from the table that the D3 12 and G4 trains are from Shanghai to Beijing; The D3 1 1 train arrived in Shanghai at 8: 40 this afternoon. The time for the G3 train to arrive in Shanghai is 18: 48. So, if you want to go to Shanghai by train in the morning, you should take the D3 1 1 train.
So choose: C.