Combinatorial template functions.