Why do I have such painful diarrhea and gas on my period?

It's terrible, as if having a period wasn't bad enough! Why does this happen?