The episode is based on a body swap scenario in which no pair of bodies can swap minds more than once. The proof demonstrates that after any sequence of mind switches, each mind can be returned to its original body by using two additional individuals who have not yet swapped minds with anyone.
Wikipedia article with context and full proof