public restroom

Wrong Bathroom
Wrong Bathroom
Wrong Bathroom
Recently, I went to a concert, had to pee REALLY REALLY bad and of course the women's restroom was packed full, so I used the men's bathroom.  I thought nothing of it, until a security guard stopped me and reprimanded me.  So when is it OK to use the opposite sex's bathroom?