# Surjection and direct products in groups

Suppose $f\colon G_1 \times G_2 \times\dots\times G_n\to G_i$ given by $f(a_1,a_2,\dots,a_n)=a_i$. Prove that it is a surjective homomorphism. I got all the parts but I am having trouble with proving that it's a surjection

Thank you for the help!

Just for surjectivity: Assuming that the map is well-defined and you already showed it, for all $a_i\in G_i$, set $$x=(e_{G_1},e_{G_2},...a_i,...e_{G_n}), 1\le i\le n$$