You are reporting the paste Gale–Shapley algorithm for Stable Marriage Problem.