Interface for preventing certain items to be combinational with each other

Suppose that I have three lists with items [A1, ..., A10], [B1, ..., B10] and [C1, ..., C10] and I apply the cartesian product on those lists. Then I will get [[A1, B1, C1], [A2, B1, C1], ...]

Now I need a user interface that allows a user to define not allowed combinations, for example B1 and C1 cannot be in the same combination.

I have thought about a matrix, but that seems quite cumbersome with many items.