Ok got this cleared,
Here is the detailed solution for the question.
When we compute for gof, the range of f is the domain of g. So on computing f first, we end up with the values \left\{ 3,5,7 \right\} which on proceeding further leads to \left\{7,9,10 \right\}
So we finally have gof as \left\{(1,7),(2,9),(3,10) \right\}
But when we take g first for fog, range of g must be \left\{ 1,2,3 \right\} which is not the case here. Thus, its not defined
EDIT: Didn't see your post Anirudh. Yes, the reason is correct. Thanks