x:=list f:=method(n,a,b,c,if(n>0,f(n-1,a,c,b);a print;x push(c);f(n-1,b,a,c))) f(File standardInput readLine asNumber,"A","B","C") write(" ",x join)