#!/usr/bin/env python3 W=[(0,0,1,2,2,1),(0,1,0,2,1,2),(1,0,2,0,2,1),(2,2,1,0,0,1)] U=set() for w in W: n=len(w) for mask in range(1,1<>i