Let x be the age of Sam and y be the age of Tomas. The sum of the ages of Sam and Tomas is 27 years. In symbols:
x + y = 27
Seven years ago, Tomas's age was y-7. Meanwhile,
seven years ago, Sam's age was x-7. Therefore, the statement 
"Seven years ago,Tomas was three years more than one-fourth as old as Sam" written in symbols is
y-7 = \frac{1}{4} (x-7) + 3
You just have to solve the solution to this two equations.