integer::N character(30),allocatable::A(:,:) character(30),allocatable::B(:,:) character(30),parameter::nyanpass='nyanpass ' integer::renge=-1,i,j read *,N allocate(A(N,N)) allocate(B(N,N)) read *,A B=TRANSPOSE(A) do i=1,N do j=1,i-1 if(B(j,i).ne.nyanpass) goto 100 end do do j=i+1,N if(B(j,i).ne.nyanpass) goto 100 end do if(renge.ne.-1) then renge = -1 exit else renge = i end if 100 end do print '(i0)',renge end program