PROGRAM c167c

IMPLICIT NONE
INTEGER :: N, M, X, I, J, K
INTEGER,ALLOCATABLE :: C(:)
INTEGER,ALLOCATABLE :: A(:, :)
INTEGER,ALLOCATABLE :: B(:)

READ *, N, M, X

ALLOCATE(C(1 : N))
ALLOCATE(A(1 : N, 1 : M))
ALLOCATE(B(1 : M))

A = 0
B(0) = 0

DO I = 1, N
READ(*,*) C(I), (A(I,J), J= 1, M)
K = K + C(I)
END DO

DO J = 1, M
 DO I = 1, N
  B(J) = B(J) + A(I,J)
 END DO
 
 IF (B(J) < X) THEN
  PRINT *, '-1'
  GO TO 38
 ELSE
  DO I = 1, N
   IF (B(J) - A(I, J) >= X) THEN
   K = K - C(I)
   B(J) = B(J) - A(I,J)
   END IF
  END DO
38 END IF
END DO