program main implicit none integer::N,i,j integer,parameter::len=111 type match integer::r01,c01,r11,c11 end type match type(match),allocatable::ml(:) integer::tab(len,len) data tab/12321*0/ read *,N allocate(ml(N)) read *,(ml(i),i=1,N) do i=1,N tab(ml(i)%r01,ml(i)%c01) = 1 + tab(ml(i)%r01,ml(i)%c01) tab(ml(i)%r11,ml(i)%c11) = 1 + tab(ml(i)%r11,ml(i)%c11) end do if(ANY(tab.gt.2)) then print '(a)',"NO" else print '(a)',"YES" end if contains subroutine aprinter(array) integer*8::array(:) character*32::cformat='(i0, (1x,i0))' write(cformat(5:9),'(i0)'),size(array) write(*,cformat) array end subroutine aprinter end program main