program main implicit none character*3::b,f integer*8::N,bx,fx,i,bp,fp data bx,fx/2*0/ read *,b,N,f do i=1,3 if(b(i:i).eq.'x') bx = bx + 1 if(f(i:i).eq.'x') fx = fx + 1 end do if(bx.ne.fx) then print '(a)', "SUCCESS" return else if(bx.eq.3.or.bx.eq.0) then print '(a)', "FAILURE" return end if if(bx.eq.1) then bp = SCAN(b,'x') fp = SCAN(f,'x') else bp = SCAN(b,'o') fp = SCAN(f,'o') end if if(N.eq.0) then if(bp.ne.fp) then print '(a)', "SUCCESS" return else print '(a)', "FAILURE" return end if else if(N.eq.1) then if((bp.eq.1.and.fp.eq.3).or. & (bp.eq.3.and.fp.eq.1).or. & (bp.eq.2.and.fp.eq.2) ) then print '(a)', "SUCCESS" return else print '(a)', "FAILURE" return end if else print '(a)', "FAILURE" return end if end program main