Stable marriage algorithm