main=interact(['0'..]%) l%(a:b)|x<-l!!read[a]=x:(x:filter(/=x)l)%b l%x=x