Credit: AP/Maria Ximena Spain to grant residency, work permits to hundreds of thousands of migrants in the country illegally