The stepwise photochromic reactivity of diarylethene tuned by selective ions and fabrication of a molecular logic circuit