Spain to grant residency and work permits to around 300,000 undocumented migrants per year