The triangles are similar to each other due to the AA (angle angle) postulate. The top angles are overlapping or shared angles. So that's the first pair. The second pair of angles is either bottom pair of angles, from the fact that corresponding angles are congruent. This is only true if the lines are parallel.
Due to the similar triangles, we can set up the proportion and solve for x 8/(8+4) = 12/x 8/12 = 12/x 8*x = 12*12 ... cross multiply 8x = 144 x = 144/8 x = 18