A teenage girl and 39-year old man, who desecrated a mosque by attacking it with strips of bacon, have both been given custodial sentences.