0 0 0 0 0 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 # first possibly valid set, though having 1 2 3 4 6 # 1 2 3 be from the same school lets you 1 2 3 4 7 # quickly skip obviously invalid matchings ... # getting to something like 1 4 7 11 14 # <- fairly quickly ... 1 2 3 4 105 ... 1 2 3 104 105 ... 101 102 103 104 105 # last possible value