for m in range(1,22):
for n in range(1,22):
for p in range(1,22):
for q in range(1,22):
if (7-m)*(7-n)*(7-p)*(7-q)==4 and len(set([m,n,p,q]))==4:
print(m,n,p,q,"=",m+n+p+q)
for m in range(1,22):
for n in range(1,22):
for p in range(1,22):
for q in range(1,22):
if (7-m)*(7-n)*(7-p)*(7-q)==4 and len(set([m,n,p,q]))==4:
print(m,n,p,q,"=",m+n+p+q)