Phosphorene and Graphene Nanoribbons with Vacancies in Magnetic Field