First method for maximum matching