Cross your mind.

Meaning: To suddenly think of something.