Let the observer be at O, the top of the building at B, and the top of the flagstaff at F, making the vertical heights 30 m, 25 m, and 30 m respectively. Let the horizontal distance of the observer from the building be x, so the horizontal distances from O to the vertical lines through B and F are both x. Using the tangent of the angle of elevation for the top and bottom of the flagstaff, we get tan(a) = (30 - 30)/x = 0 for the top, which contradicts the geometry; correctly interpreting the setup, the observer is horizontally distant x, giving tan(theta) = 5/sqrt(x^2 + 25) and tan(phi) = 25/sqrt(x^2 + 400). Equating the angles gives 5/sqrt(x^2 + 25) = 25/sqrt(x^2 + 400), so sqrt(x^2 + 400) = 5sqrt(x^2 + 25). Squaring yields x^2 + 400 = 25x^2 + 625, meaning 24x^2 = 225, so x = 5sqrt(3/2).