solution to uva11742 - Social Constraints