Interaction between magnetic boundary and first wall recycling in the reversed field pinch