Counting functions on the set {1, 2, 3}

Hello!

I'm unsure of how to attack the following problem. It states that $\displaystyle F_{3}$ denotes the set of all functions from {1, 2, 3} to {1, 2, 3}, then asks one to find the number of functions *f* ∊ $\displaystyle F_{3}$ such that (f ∘ f)(1) = 3. Simpler questions are clear to me -- I see, for example, that the total number of functions is 3^3 and that there are 3^2 functions where f(1) = 3 -- but I'm not sure of a reasonable way to find how many have (f ∘ f)(1) = 3. I drew out the full tree of 27 possible functions to find that there are six such possible functions, then reasoned backward to the following process:

- Make f(2) = 1 or f(3) = 1. (2 ways.)
- Make f(1) = 3. (1 way.)
- Map remaining input onto any one of three outputs. (3 ways)

This yields 2*3 = 6 functions with (f ∘ f)(1) = 3, but this method seems wrong, and so I question whether there's a more intuitive way to go about it.

The second related problem I'm struggling with asks one to find the number of ordered pairs (f, g) of functions in $\displaystyle F_{3}$ so that (f ∘ g)(1) = 3. On this one, I have no idea where to begin.

Any assistance you can offer will be much appreciated. Thanks!