Sets in a four-partite graph

EOlymp - 105