main=readLn>>=(f[]!!) f x=putStr["ABC\n"!!a|a<-reverse x++3:2#x]:f(1#x++0:0#x) n#x=[mod(n-m)3|m<-x]