for(T={};Q=readline();/\?/.test(Q)?print(Q.replace('?',T[L]||T[R])):T[T[R]=L]=R)L=Q[0],R=Q[2]