program main implicit none integer::n integer::a(100) integer::i,j,k,x,y,r,p,q,tmp read*,n a(1)=0 a(2)=1 do i=3,n x=xor(a(i/2),a(i-i/2)) if(mod(i,3)==0.or.mod(i,3)==1)then y=a(i/3) else if(mod(i,3)==0)then y=a(i/3+1) end if if(x>=y)then x=tmp x=y y=tmp end if if(x/=0.and.y/=0)then a(i)=0 else if(x/=1.and.y/=1)then a(i)=1 else a(i)=2 end if end do if(a(n)==0)then print*,"B" else print*,"A" end if end program