Codeforces Beta Round #55 Problem D Team Arrangement