f=1,*1..100 eval"f[#$`],f[#$']=f[#$'],f[#$`]"if/ / while gets p f.reduce{|x,k|a=k;x.lcm~f.index{k==a=f[a]}}