thus , residents registered in rural districts were given only severely restricted access to education , welfare , medical , and housing benefits , and were not legally permitted to stay in the city for extended periods of time .