^ = AND v = OR ¬ = not

a5,a4,a3,a2,a1

b5,b4,b3,b2,b1

--------------

s5,s4,s3,s2,s1

X#Y = ¬(A^B)^(AvB)

s1 = a1#b1 s2 = (a2#b2)#(a1^b1) s3 = (a3#b3)#((a2^b2)v((a2#b2)^(a1^b1))) s4 = (a4#b4)#((a3^b3)v((a3#b3)^(a2^b2))v((a3#b3)^(a2#b2)^(a1^b1))) s5 = (a5#b5)#((a4^b4)v((a4#b4)^(a3^b3))v((a4#b4)^(a3#b3)^(a2^b2))v((a4#b4)^(a3#b3)^(a2#b2)^(a1^b1)))