Q=range(4)
QZ=range(1,4)
def checkvects(V=[]):
        l=len(V)
        if l==4:
##RISULTATO: solo con l==2 ho soluzioni
                s=''
                for (w1, w2) in V:
                        s+='  %2d,%2d'%(w1,w2)
                print ' '*l,s
        for i in xrange(4-l):
                for v1 in Q:
                        for v2  in [1,-1]:
                                check=1
                                for (w1, w2) in V:
                                        if not checkvw(v1, v2, w1, w2):
                                                check=0
                                                break
                                        if is_equal(v1, v2, w1, w2):
                                                check=0
                                                break
                                if check:
                                        checkvects(V[:]+[(v1,v2)])

def checkvw(v1, v2, w1, w2):
        for a in QZ:
                for b in QZ:
#               print '>>>', '(',v1,v2,')', ' ', '(',w1,w2,')', ((a*(v1+w1))%4), ((a*(v2+w2))%4)
                        if (a*v1)%4 == (b*w1)%4 and (a*v2)%4 == (b*w2)%4:
                                return 0
        return 1

def is_equal(v1, v2, w1, w2):
        if v1 == w1 and v2 == w2:
                return 1
        if v1 == -w1 and v2 == -w2:
                return 1
        return 0

checkvects()
