Suppose A1, A2, ..., A30 are thirty sets each having 5 elements and B1, B2, ..., Bn are n sets each having 3 elements. Let \(\bigcup_{i=1}^{30} A_i = \bigcup_{j=1}^{n} B_j = S\) and each element of S belongs to exactly 10 of the Ai's and exactly 9 of the Bj's, then find the value of n.
\( S = \{1, 2, 3\} \), \( f : S \to S \) satisfies the property: \( \forall x \in S,\, f(f(x)) = f(x) \). How many different functions are there for \( f(x) \)?[Note: Can you generalize the result for \( S = \{1, 2, 3, \ldots, n\} \)?]