Analysis help--> Suppose that g1: A1 → A2 and g2 : A2 → A3. If B ⊂ A3...

Suppose that g1: A1 → A2 and g2 : A2 → A3. If B ⊂ A3, show that

a) (g2 ◦ g1)^(−1)(B) = g^(−1)1 (g^(−1)2 (B)).

b) Now suppose that n ≥ 2 and gi : Ai → Ai+1 for i = 1, 2, . . . n. If B ⊂ An+1 show that

(gn ◦ gn−1 ◦ . . . ◦ g2 ◦ g1)^(−1)(B) = g^(−1)1 (g^(−1)2 (. . . (g^(−1)n (B))))

My attempt:

a) first, g^(-1)2(B) = {x belongs toA2 : g2(x) belongs to B}

--> g^(-1)(g^(-1)2(B)) = g^(-1)1({x belongs to A2 : g2(x) belongs to B})

--> g^(-1)1({x belongs to A2 : g2(x) belongs to B}) = {y belongs to A1 : g1(y) belongs to {x belongs to A2 : g2(x) belongs to B}}

-->g^(-1)1(g^(-1)2(B)) = {y belongs to A1 : (g2 ◦ g1)^(-1)(y) belongs to B}

Which by definition = ((g2 ◦ g1)^(−1)(B)

b) im not sure how to do part B, can anybody help me. Would i need to use induction? I apologize if this all looks confusing, i tried to make it as clear as possible.

Thanks