The foci of an ellipse are at $(3,7)$ and $(d,1).$ The ellipse is tangent to both the $x$-axis and the $y$-axis. Compute $d.$