Let's denote the initial amounts of money that Grace and Andy received as \( G \) and \( A \), respectively. According to the problem, they shared their money in the ratio \( 5:8 \). This can be expressed using a common variable \( k \):
\[ G = 5k \quad \text{and} \quad A = 8k \]
Next, Grace receives $108 from her mother and Andy receives $39 from his father. After these additions, their total amounts become:
\[ G + 108 \quad \text{and} \quad A + 39 \]
According to the problem, they now have the same amount of money:
\[ G + 108 = A + 39 \]
Substituting the expressions for \( G \) and \( A \):
\[ 5k + 108 = 8k + 39 \]
Now, we can solve for \( k \):
\[ 5k + 108 - 39 = 8k \] \[ 5k + 69 = 8k \] \[ 69 = 8k - 5k \] \[ 69 = 3k \] \[ k = \frac{69}{3} = 23 \]
Now, we can find the initial amounts \( G \) and \( A \):
\[ G = 5k = 5 \times 23 = 115 \] \[ A = 8k = 8 \times 23 = 184 \]
Thus, Grace initially had $115 and Andy initially had $184.
In summary:
- Grace initially had \( \boxed{115} \)
- Andy initially had \( \boxed{184} \)