Let $ABCD$ and $BCFG$ be two faces of a cube with $AB=12.$  A beam of light emanates from vertex $A$ and reflects off face $BCFG$ at point $P,$ which is 7 units from $\overline{BG}$ and 5 units from $\overline{BC}.$  The beam continues to be reflected off the faces of the cube.  The length of the light path from the time it leaves point $A$ until it next reaches a vertex of the cube is given by $m\sqrt{n},$ where $m$ and $n$ are integers and $n$ is not divisible by the square of any prime.  Find $m+n.$
1. **Understanding the Problem:**
   - We have a cube with side length \( AB = 12 \).
   - A beam of light emanates from vertex \( A \) and reflects off face \( BCFG \) at point \( P \).
   - Point \( P \) is 7 units from \( \overline{BG} \) and 5 units from \( \overline{BC} \).
   - We need to find the length of the light path from \( A \) until it next reaches a vertex of the cube.

2. **Locating Point \( P \):**
   - Since \( P \) is 7 units from \( \overline{BG} \) and 5 units from \( \overline{BC} \), we can place \( P \) at coordinates \( (12, 5, 7) \) in a coordinate system where \( A = (0, 0, 0) \), \( B = (12, 0, 0) \), \( C = (12, 12, 0) \), and \( G = (12, 12, 12) \).

3. **Reflection Path:**
   - The light beam reflects off the face \( BCFG \) and continues to reflect off other faces of the cube.
   - Each reflection changes the direction of the beam but maintains the same distance traveled in each coordinate direction.

4. **Finding the Next Vertex:**
   - The beam moves 5 units in the \( y \)-direction and 7 units in the \( z \)-direction with each reflection.
   - We need to find the smallest \( x \) such that both \( 5x \) and \( 7x \) are multiples of 12 (the side length of the cube).

5. **Finding the Least Common Multiple:**
   - The least common multiple of 5 and 7 is 35.
   - Therefore, \( x = 12 \) is the smallest value such that \( 5x \) and \( 7x \) are multiples of 12.

6. **Calculating the Distance:**
   - The distance from \( A \) to \( P \) is given by:
     \[
     AP = \sqrt{(12)^2 + (5)^2 + (7)^2} = \sqrt{144 + 25 + 49} = \sqrt{218}
     \]
   - Since \( x = 12 \), the total distance traveled is:
     \[
     12 \times \sqrt{218} = 12\sqrt{218}
     \]

7. **Final Calculation:**
   - The length of the light path is \( 12\sqrt{218} \).
   - Here, \( m = 12 \) and \( n = 218 \).
   - Therefore, \( m + n = 12 + 218 = 230 \).

The final answer is \( \boxed{230} \).