program pyramid
  implicit none
  integer              :: n, highest, idx, i, j, k, hc
  integer, allocatable :: x(:), y(:), h(:)
  logical              :: invalid
  read(*,*) n
  allocate(x(n),y(n),h(n))
  highest = 0
  idx = 0
  do i = 1, n
     read(*,*) x(i),y(i),h(i)
     if (h(i) .gt. highest) then
        highest = h(i)
        idx = i
     end if
  end do
  do i = 0, 100
     do j = 0, 100
        hc = highest + abs(i-x(idx)) + abs(j-y(idx))
        invalid = .false.
        do k = 1, n
           if (h(k) .ne. hc - abs(i-x(k)) - abs(j-y(k))) then
              invalid = .true.
              exit
           end if
        end do
        if (invalid) cycle
        write(*,'(i0,x,i0,x,i0)') i, j, hc
        stop
     end do
  end do
  deallocate(x,y,h)
  stop
end program pyramid