UEFA Champions League Draw

From 8 groups of 4 teams, you have 16 teams advancing to the next stage playoffs.

1- A team cannot play against another of the same group from the group-stage.
2- A team cannot face another from the same national league.

What would be the optimal way to model this problem in a functional railway-oriented way.

Something I saw in OO code was one team uber-object with states for each stage of the games and status flags … complicated and just doesn’t look right

This problem seems a better fit for a constrain satisfaction solver, than a pipeline method. Here’s a small sample for a completely different problem just to give you an idea: