CMIMC 2021 Team Problem 10

How many functions f:\{1,2,3, \ldots, 7\} \rightarrow\{1,2,3, \ldots, 7\} are there such that the set \mathcal{F}=\{f(i): i \in\{1, \ldots, 7\}\} has cardinality four, while the set \mathcal{G}=\{f(f(f(i))): i \in\{1, \ldots, 7\}\} consists of a single element?