I know how to solve each of those problems. For the set one, I look at the output of the S and try to match it with the input of T and then take the pair (input_of_S, output_of_T), and I do that for each pair.
As for the formula one, I just plug in x = g(y).
My confusion lies in trying to...