[1 1 0 1 0] → [Au Pb] [1 1 0 0 1] → [Ag Pb] [1 1 0 0 0] → [Au Fe] [1 0 1 1 1] → [Pb Fe] [1 0 1 1 0] → [Cu Fe] [1 0 1 0 1] → [Fe Fe] [1 0 1 0 0] → [Sn Ag] [1 0 0 1 1] → [Sn Fe] [1 0 0 1 0] → [Pb Ag] [1 0 0 0 1] → [Ag Fe] [1 0 0 0 0] → [Fe Ag] [0 1 1 1 1] → [Pb Sn] [0 1 1 1 0] → [Cu Sn] [0 1 1 0 1] → [Fe Sn] [0 1 1 0 0] → [Au Au] [0 1 0 1 1] → [Sn Sn] [0 1 0 1 0] → [Au Sn] [0 1 0 0 1] → [Ag Sn] [0 1 0 0 0] → [Au Cu] [0 0 1 1 1] → [Pb Cu] [0 0 1 1 0] → [Cu Cu] [0 0 1 0 1] → [Fe Cu] [0 0 1 0 0] → [Sn Au] [0 0 0 1 1] → [Sn Cu] [0 0 0 1 0] → [Pb Au] [0 0 0 0 1] → [Ag Cu] [0 0 0 0 0] → [Fe Au] The first metal is determined as follows: IF(E=1 AND D=1 AND C=1): Pb IF(E=1 AND D=1 AND C=0): Sn IF(E=1 AND D=0 AND C=1): Fe IF(E=0 AND D=1 AND C=1): Cu IF(E=1): Ag IF(D=1 AND C=0 AND B=0): Pb IF(D=0 AND C=1 AND B=0): Sn IF(D=0 AND C=0 AND B=0): Fe ELSE: Au The second metal is determined as follows: IF(A=1 AND B=1): Pb IF(B=1): Sn IF(A=1): Fe ELSE: Cu IF(E=1): Send metal to output IF(D=1): Skip adding two quicksilver to the second metal IF(D=1 AND C=0 AND B=0): Add another two quicksilver to the second metal IF(D=0 AND C=1 AND B=1): Add another two quicksilver to the second metal