unary and pairwise template