Spain to grant residency, work permits to migrants living in the country illegally