Answer:
<h2>After 36 seconds.</h2>
Step-by-step explanation:
To find the answer to this problem, we have to sum each period of time for each train, and see where they use the same time. Train A will return each 12 seconds and Train B will return each 9 seconds, this means that we have to build two sequences with this increasing numbers.
A       B
12      9
24     18
36     27
48     36
As you can observe in the sequences, after 36 seconds both trains will arrive at the starting points at the same time. To reach such time equivalence, the train A has to make three laps, and train B hast to make 6 laps.
Therefore, the answer is "after 30 seconds".