DistinctRepresentatives( L )
When L is a set of n subsets of [1..n] and the Hall condition is satisfied (the union of any k subsets has at least k elements), a standard algorithm for systems of distinct representatives is applied. (A backtrack algorithm would be more efficient.) If the elements of L are lists, they are converted to sets.
gap> DistinctRepresentatives( J ); [ 1, 3, 4, 2 ]
GAP 3.4.4