PROGRAM pythag
  IMPLICIT NONE
  INTEGER :: m,n,a,b,c
  
  m = 1
  outer: DO
     DO n = 1,m-1
        a = m*m-n*n
        b = 2*m*n
        c = m*m+n*n

        IF (a+b+c==1000) EXIT outer
     END DO
     m = m + 1
  END DO outer

  PRINT *, a, b,c
END PROGRAM pythag
