Girl travelling without a mahram to acquire deeni knowledge
Q: We know from the hadith that a woman is not allowed to travel at all a distance more than 3 days and 3 nights (78km) without a mahram. But would this prohibition be relaxed in the case where a female has to acquire deeni knowledge?
Example, in her home town there are absolutely no madrasahs. So a girl travels without a mahram for more than the safar distance and then joins a girls' boarding madrasah and lives there. Will this be permissible under the circumstances?
If not allowed: what is the status of her acquiring knowledge, will her ibaadaat be accepted there, etc?