Its not that important, it all depends what kind of shot you are after, the flash will work in P A S and M
P is a programmed auto mode,
if you want to specify shutter speed ie to capture a fast moving subject or to show "movement" in a photo use S
If you want to show everything in the photo in focus or to exagerate DOF (depth of field) ie the main subject is in focus and the background is blurred use A
M is full manual where you can set everything yourself.
Remember if you use S and you set the shutter speed the aperture is set for you and visa versa if you use A
edit - Just found
this for you, this gives a good explanation from someone who can put it in better words than I can :-)