Tridiagonal and upper triangular inverse M-matrices