you cant get pregnant

without having a dick inside of you right ? like if theres no dick no baby but my question is does it literally have to be insterted in you to get pregnant or just by touching sperm and touching yourself you can get pregnant ?