Doubt in valentine magic problem

Sir/Mam in this somewhere sir write
if(j==m){
all girls are rejected}
and
for boys
{if(i==n)
all boys are paired}
My ques. in case of girls why we write all girl rejected not all girl all pair

@Royal_Yashasvi
Here we are trying to pair the ith boy with jth girl.
So here j represents the girl which can be paired with ith boy.
so if j==m which means that there is no girl left for the ith boy to pair.
and i==n means there are no boys left which needs to be paired. (i and j are 0-based index).