Help me , about incoming call , i want the set extension will ring

I have 4 PSTN Line + TDM card 1(PC),(4FXO port)

FXO1 link the PSTN Line1
FXO2 link the PSTN Line2
FXO3 link the PSTN Line3
FXO4 link the PSTN Line4

I want to do :
When the call incoming from PSTN Line1 , the extension401、402 will ring
When the call incoming from PSTN Line2 , the extension801、802 will ring
When the call incoming from PSTN Line3 , the extension401、801 will ring
When the call incoming from PSTN Line4 , the extension402、802 will ring

Could you help me how to config the freepbx ?
how to config the DIDs and how to distinguish the call from which Port(which PSTN Line)?

thanks very much.