The first term of a G.P is 7, the last term is 567 and sum of terms is 847. Find the common ratio of the G.P.