Whenever we are given one function and must calculate a funciton of the funciton, such as g(f(x)) in this case, we simply substitute the second function, f(x) in this case, in the first function, g(x) in this case, wherever the first function has a variable. Therefore,
g(f(x)) = (3x + 2)^2 + 1
g(f(x)) = 9x^2 + 12x + 4 + 1
g(f(x)) = 9x^2 + 12x + 5