Should you take ibuprofen for a headache or menstrual cramps?

Should you take ibuprofen for a headache or menstrual cramps?