How to check for correct order in a fill-in-the-blanks exercise

Suppose the following fill-in-the-blanks exercise:

___ ___ and ___ ___ went to the ___.

Suppose the correct solution here is "John Smith and Mike Jones went to the pub". In other words: [John, Smith, Mike, Jones, pub].

But the following alternate solution should count as well - the persons are swapped but they are the correct people: [Mike, Jones, John, Smith, pub]. But, this next one definitely should not count as correct: [Mike, Smith, John, Jones, pub] because the names and surnames are mixed up.

OK. In order to make this work, I could hard-code two alternate orderings like so, and check the answers provided against them:

[
[John, Smith, Mike, Jones, pub],
[Mike, Jones, John, Smith, pub]
]


but this does not scale well. What if the sentence gets longer and their names and surnames appear again? What if another person joins? The number of combinations would grow quickly.

How should I approach this problem?

We could use [[John, Smith], [Mike, Jones], pub]. Therefore, we know [John, Smith] should be treated as one, as well as [Mike, Jones].